How do I trigger a mousemove event in an angularjs unit test

余生颓废 提交于 2019-12-01 09:16:07

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!