I've set up a simple function to handle mouse wheel events on a menu component I built. The component works fine, I'm trying to write a unit test around it and that is giving me an issue.
component handler:
handleWheel: function (event) {
(event.deltaY < 0 ) ? this.moveUp() : this.moveDown();
return false;
}
this.moveUp() / this.moveDown() simply sets the state of firstIndex
The issue is that when I try to write a test for this functionality I can't get it to work. I'm almost 100% certain it has to do with the eventDetails object i'm passing in, but I don't know how to format it correctly.
// set firstIndex = 0
TestUtils.Simulate.scroll(menu, {deltaY: 52});
expect(menu.state.firstIndex).to.equal(1);
// error: expected 0 to be 1
Does anyone know how to correctly format the TestUtils.Simulate.Scroll() / know of a better way to test onWheel() ?
Click and hold the middle button (press the scroll wheel down) of your mouse. The scroll wheel should turn blue on the picture. If you let go of the scroll wheel, the scroll wheel on the picture should stay light blue.
Hover your mouse pointer over the canvas and scroll in one direction as fast as you can. The program will draw a colored streamer moving to the right and also in the direction you're scrolling. As long as you don't change scrolling direction, the streamer should stay the same color.
Mouse Scroll Test, aka Roller Speed test or Scroll Speed Test, is a test to measure your scrolling speed. Have you ever wondered how many pixels you can scroll per second? Take this test now to find out. All you have to do is to scroll your mouse as fast as possible.
If the event handler is for onWheel you should use Simulate.wheel
.
There's a 1:1 mapping of events to Simulate methods. Remove the "on" and lowercase the first letter.
onScroll -> Simulate.scroll
onKeyDown -> Simulate.keyDown
onWheel -> Simulate.wheel
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With