Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX beta] fillIn test helper triggers input event. #11708

Merged
merged 1 commit into from
Jul 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/ember-testing/lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ function fillIn(app, selector, contextOrText, text) {
$el = app.testHelpers.findWithAssert(selector, context);
focus($el);
run(function() {
$el.val(text).change();
$el.val(text);
$el.trigger('input');
$el.change();
});
return app.testHelpers.wait();
}
Expand Down
33 changes: 33 additions & 0 deletions packages/ember-testing/tests/helpers_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,39 @@ QUnit.test('`fillIn` focuses on the element', function() {
});
});

QUnit.test('`fillIn` fires `input` and `change` events in the proper order', function() {
expect(1);

var fillIn, visit, andThen;
var events = [];
App.IndexController = Ember.Controller.extend({
actions: {
oninputHandler(e) {
events.push(e.type);
},
onchangeHanlders(e) {
events.push(e.type);
}
}
});

App.IndexView = EmberView.extend({
template: compile('<input type="text" id="first" oninput={{action "oninputHandler"}} onchange={{action "onchangeHanlders"}}>')
});

run(App, App.advanceReadiness);

fillIn = App.testHelpers.fillIn;
visit = App.testHelpers.visit;
andThen = App.testHelpers.andThen;

visit('/');
fillIn('#first', 'current value');
andThen(function() {
deepEqual(events, ['input', 'change'], '`input` and `change` events are fired in the proper order');
});
});

if (isEnabled('ember-testing-checkbox-helpers')) {
QUnit.test('`check` ensures checkboxes are `checked` state for checkboxes', function() {
expect(2);
Expand Down