Skip to content Skip to sidebar Skip to footer

How Do I Trigger A Mousemove Event In An Angularjs Unit Test

I have implemented an angularjs directive that use mouse event; clicking on component and moving mouse up or down it can changes a value. So i need to know how do I trigger a mouse

Solution 1:

This blog article shows an example using jqLite's triggerHandler().

Triggering Events in Angular JS Directive Tests

EDIT: Okay, I made a Plunker quickly to demonstrate how you can pass parameters too: link. Check the console output to see the parameters on the event object. You can add anything your implementation might need.

So you can pass data like this for example:

elem.triggerHandler({type :"mousemove",pageX:48,pageY:102});

So you will need to get a handle on your element with angular.element and then use above code to trigger events on it.

Post a Comment for "How Do I Trigger A Mousemove Event In An Angularjs Unit Test"