day 255 — code 365
Thu 25 Aug 2016
React
Found out that keyDown is required to simulate an event when testing a component using Enzyme. This might be because I haven’t understood the API properly, but what I found was this:
This doesn’t trigger a function that listens to this:
wrapper.find('input').simulate('keyPress', [{ charCode: 13 }]);However, this does:
wrapper.find('input').simulate('keyDown', [{ which: 13 }]);Also, I found out that which is preferred over keyCode:
The event.which property normalizes event.keyCode and event.charCode. It is recommended to watch event.which for keyboard key input.
Git
Realised that I feel a lot more comfortable resolving merge conflicts!!
The >>>>>>>>>>>>>> no longer freaks me out so much.
I think it’s because I understand what the code is supposed to do!!