react-resize-observer icon indicating copy to clipboard operation
react-resize-observer copied to clipboard

Add Some Tests

Open JustinNusca opened this issue 7 years ago • 1 comments

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

  • Adds homepage, bugs, and repository fields to the package.json file. ad6496c
  • Adds enzyme & enzyme-adapter-react-16 dependencies and updates other deps accordingly. 32db9e6, cd8cf8f
    • A number of moderate and high security vulnerabilities were detected in the devDependencies when running npm audit, which was resolved via the automated npm audit fix command.
  • Fixes a typo: removeSResizeListenerremoveResizeListener. 72c2ad9
  • Adds a test suite for the components prop interface. 53c6c7c

JustinNusca avatar Jul 30 '18 20:07 JustinNusca

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! 🎉

izaakschroeder avatar Jul 30 '18 20:07 izaakschroeder