I have an imageViewer component (guess what that does) that itself has a hotkey component to rotate the image.... Everything works fine but I somehow can't get jest to actually test that the hotkey rotates the image.
I've tried many things including throwing an input tag in there to test the hotkey on, using wrapper.find().simulate like this question.... I've also driven several of my teammates to insanity and no one can figure it out.
let hotkeynode = <div><ImageViewer rotateable={true} img={landscapeImg} /><input type='text'/></div>;
it("rotates on hotkey", () => {
const wrapper = felaMount(hotkeynode);
// wrapper.find('input').simulate('keypress', { 'ctrlKey': true, 'key': 'left' });
ReactTestUtils.Simulate.keyPress('input', {'ctrlKey': true, 'key': 'left', 'keyCode': 37});
expect(wrapper.find(ImageViewer).instance().state.imgDeg).toEqual(90);
Aucun commentaire:
Enregistrer un commentaire