Skip to content

Commit

Permalink
[BUGFIX beta] Fix mouseenter typo in ember-testing helpers (#13310)
Browse files Browse the repository at this point in the history
(cherry picked from commit 3970129)
  • Loading branch information
jakesjews authored and rwjblue committed Apr 12, 2016
1 parent 162828a commit 614292e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/ember-testing/lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var keyboardEventTypes, mouseEventTypes, buildKeyboardEvent, buildMouseEvent, bu
if (isEnabled('ember-test-helpers-fire-native-events')) {
let defaultEventOptions = { canBubble: true, cancelable: true };
keyboardEventTypes = ['keydown', 'keypress', 'keyup'];
mouseEventTypes = ['click', 'mousedown', 'mouseup', 'dblclick', 'mousenter', 'mouseleave', 'mousemove', 'mouseout', 'mouseover'];
mouseEventTypes = ['click', 'mousedown', 'mouseup', 'dblclick', 'mouseenter', 'mouseleave', 'mousemove', 'mouseout', 'mouseover'];


buildKeyboardEvent = function buildKeyboardEvent(type, options = {}) {
Expand Down
32 changes: 32 additions & 0 deletions packages/ember-testing/tests/helpers_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,38 @@ QUnit.test('`click` triggers native events with simulated X/Y coordinates', func
});
});

QUnit.test('`triggerEvent` with mouseenter triggers native events with simulated X/Y coordinates', function() {
expect(5);

var triggerEvent, wait, evt;

App.IndexView = EmberView.extend({
classNames: 'index-view',

didInsertElement() {
this.element.addEventListener('mouseenter', e => evt = e);
}
});


Ember.TEMPLATES.index = compile('some text');

run(App, App.advanceReadiness);

triggerEvent = App.testHelpers.triggerEvent;
wait = App.testHelpers.wait;

return wait().then(function() {
return triggerEvent('.index-view', 'mouseenter');
}).then(function() {
ok(evt instanceof window.Event, 'The event is an instance of MouseEvent');
ok(typeof evt.screenX === 'number' && evt.screenX > 0, 'screenX is correct');
ok(typeof evt.screenY === 'number' && evt.screenY > 0, 'screenY is correct');
ok(typeof evt.clientX === 'number' && evt.clientX > 0, 'clientX is correct');
ok(typeof evt.clientY === 'number' && evt.clientY > 0, 'clientY is correct');
});
});

}

QUnit.test('`wait` waits for outstanding timers', function() {
Expand Down

0 comments on commit 614292e

Please sign in to comment.