Open JustinNusca opened 6 years ago
I haven't really dug in too deep but I appreciate having tests either way! 😄Unfortunately this kind of library is really hard to test properly without actual browser testing since it exploits some very funny behaviour of scroll events. You can look into puppeteer
which has some support for jest
to do integration testing if you really want to go down that road.
Either way this is a great start! Thanks! 🎉
Summary
This PR adds
enzyme
and an appropriate adapter to the devDependencies, and uses them to run a newly-added test suite.I wanted to avoid testing specific implementation details, instead focusing on the prop interface (ie, the onReflow/Resize/Position callback props), and ensuring that they were being called (or not called) in the appropriate scenarios.
Coverage is unfortunately not 100% just yet — I had some concerns around the handling of the actual calls to
add/removeEventListener
, and recent changes that may be preventing the event listener from being appropriately cleaned up when the last component instance is unmounted that I think should be resolved first.I also needed to move onto some other tasks, but I felt it would be better to submit my work so far and revisit it later, rather than hold onto it until it's complete.
Changes
package.json
file. ad6496cenzyme
&enzyme-adapter-react-16
dependencies and updates other deps accordingly. 32db9e6, cd8cf8fnpm audit
, which was resolved via the automatednpm audit fix
command.removeSResizeListener
→removeResizeListener
. 72c2ad9