diff --git a/src/acceptance.js b/src/acceptance.js index f3de659..522bebb 100644 --- a/src/acceptance.js +++ b/src/acceptance.js @@ -162,6 +162,30 @@ export function mouseMove(selector, options) { triggerMouseEvent(mouseMove, selector, options); } +/** + * Waits for an element to show up, and then simulates a user mouse over by triggering a mouse event on that element. + * @param {string|jQuery} selector The jQuery selector or jQuery object to simulate mouse move on. + * Note that the selector or jQuery object must represent exactly one (1) element in the app, or the call will fail. + * @param {object} [options] Any options to pass along to the simulated mouse event. + * @example + * mouseDown('.element-to-mouse-move-on', { clientX: 1337, clientY: 1338 }); + */ +export function mouseOver(selector, options) { + triggerMouseEvent(mouseOver, selector, options); +} + +/** + * Waits for an element to show up, and then simulates a user mouse out by triggering a mouse event on that element. + * @param {string|jQuery} selector The jQuery selector or jQuery object to simulate mouse move on. + * Note that the selector or jQuery object must represent exactly one (1) element in the app, or the call will fail. + * @param {object} [options] Any options to pass along to the simulated mouse event. + * @example + * mouseDown('.element-to-mouse-move-on', { clientX: 1337, clientY: 1338 }); + */ +export function mouseOut(selector, options) { + triggerMouseEvent(mouseOut, selector, options); +} + /** * Waits for an element to show up, and then simulates a user touch start by triggering a touch event on that element. * @param {string|jQuery} selector The jQuery selector or jQuery object to simulate touch on. diff --git a/tests/acceptance/mouse-events.test.js b/tests/acceptance/mouse-events.test.js index 1b0928b..8505df5 100644 --- a/tests/acceptance/mouse-events.test.js +++ b/tests/acceptance/mouse-events.test.js @@ -4,6 +4,8 @@ import { mouseDown, mouseUp, mouseMove, + mouseOver, + mouseOut, setupAsync, andThen, jQuery as $ @@ -31,6 +33,8 @@ describe('Mouse Events', () => { describeMouseEventHelper(mouseDown, 'mousedown'); describeMouseEventHelper(mouseUp, 'mouseup'); describeMouseEventHelper(mouseMove, 'mousemove'); + describeMouseEventHelper(mouseOver, 'mouseover'); + describeMouseEventHelper(mouseOut, 'mouseout'); function describeMouseEventHelper(helperToTest, eventName, extraTests = ()=> { }) {