How to test a React hooks which is binding a global window/document event(s):
This is an easy approach for testing DOM events in hooks/components without actually emmitting/triggering any "fake" events, which is much easier:
- In the tests file, create a dummy React component and call the hook. if the hook is returning something, then assign it to a varaible which should be defined from outside the component so it will be available for the tests cases.