0

I'm writing a javascript library that does something on window.onmousemove event, now I'm writing the unit test for this code. How do I fire onmousemove for window object manually? For eg. I fire an event somethingHappened when window.onmousemove and other events are triggered, I want the unit test to make sure that the somethingHappened is triggered on onmousemove.

I'm using jsTestDriver with qUnit for testing.

Shawn Mclean
  • 56,733
  • 95
  • 279
  • 406

2 Answers2

0

Can't you just call window.onmousemove() anywhere you want?

if(condition) {
   window.onmousemove();
}
Andreas Wong
  • 59,630
  • 19
  • 106
  • 123
0

You can just call the onmousemove() handler:

​window.onmousemove = function(){console.log('called');}​​​​​;
window.onmousemove();​

PS

Anyway what you're trying to perform is an integration test, not a unit test

Community
  • 1
  • 1
mamoo
  • 8,156
  • 2
  • 28
  • 38