test: Add comprehensive tests for 5 previously untested hooks #1882
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add comprehensive test coverage for hooks that were missing tests:
useBoundingclientrect: 12 tests covering basic functionality, DOMRect
properties, mutation tracking, edge cases, cleanup, multiple instances,
SSR compatibility, performance, and different element types
useGlobalObjectEventListener: 24 tests covering window/document listeners,
event handling, cleanup, listener options (capture, once, passive),
conditional attachment, layout effect option, fresh callbacks, edge cases,
multiple instances, and real-world scenarios
useMergeRefs: 25 tests covering mutable refs, callback refs, mixed refs,
null/undefined handling, memoization, React component integration, edge
cases, TypeScript type safety, and performance
useRefElement: 27 tests covering basic functionality, ref callbacks,
callback stability, React integration, different element types, state
updates, multiple instances, edge cases, cleanup, and real-world use cases
useResizeObserverRef: Enhanced from 2 to 27 tests, adding coverage for
callback execution, fresh callbacks, cleanup, options (box types), ref
stability, multiple elements, element switching, edge cases, and performance
Total: 115 new tests added (126 passing, 1 skipped)
All tests follow the established patterns in the repository: