Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 630
Nikos Avatar asked Jul 15 '15 15:07

Nikos


2 Answers

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 ...
});
like image 174
Toran Billups Avatar answered Nov 15 '22 09:11

Toran Billups


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');
like image 45
Stéphane Bruckert Avatar answered Nov 15 '22 10:11

Stéphane Bruckert