Nikos
Nikos

Reputation: 7551

Simulate a select selection in ember integration test

How do you trigger selecting an <option> in a select element in an integration test? select2 is simple enough: Simulate a ember-select2 selection in ember integration test

Upvotes: 6

Views: 4101

Answers (2)

St&#233;phane Bruckert
St&#233;phane Bruckert

Reputation: 22933

I've had to do this for the underlying event code to be triggered (Ember 2.16):

find('select#my-select').val('foo').trigger('change');

Upvotes: 1

Toran Billups
Toran Billups

Reputation: 27407

A basic example for ember 1.12 or 1.13+ would use the fillIn helper. I just haven't used it with a jquery select like the one you mention above. Give this a try and report back :)

visit("/foobar");
var firstOption = find(".my-select option:eq(0)");
fillIn(".my-select", firstOption.val());
andThen(function() {
  assert.equal(find(".my-select").val(), 78); //assuming 78 is the first options value ...
});

Upvotes: 7

Related Questions