I have a problem with simulating drag event in my React Enzyme Jest unit test. Spy is never called in opposite to the dragStart and dragExit. Working ones are basing on mouse event and drag of course not - many tries of simulating it in strange ways like:
wrapper.find('Draggable').simulate('mouseDown').simulate('mouseMove', {PageY: 100}).simulate('mouseUp');
...are failed, so this is my actual describe block:
it('should call dragStart()', () => {
wrapper.find('Draggable').simulate('mouseDown');
expect(wrapper.instance().props.dragStart).toHaveBeenCalled(); // PASS
});
it('should call dragExit()', () => {
wrapper.find('Draggable').simulate('mouseDown').simulate('mouseUp');
expect(wrapper.instance().props.dragExit).toHaveBeenCalled(); // PASS
});
it('should call dragMove()', () => {
wrapper.find('Draggable').simulate('drag');
expect(wrapper.instance().props.dragMove).toHaveBeenCalled(); // FAIL
});
How can I simulate that dragging? I chose react-draggable dependency. I use enzyme mount with jest.fn() spy props to render my wrapper. Please for help and if you need any more information - just say! :)
PS: I know Draggable solution with TestUtils but I want to create same effect with Enzyme, however my efforts are ending with not called spy at all:
wrapper.find('Draggable').simulate('mouseDown', {clientX: 0, clientY: 0}).simulate('mouseMove', {clientX: 0, clientY: 100}).simulate('mouseUp');