Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Conversation

@imbhargav5
Copy link
Owner

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:

  • Use @testing-library/react-hooks for hook testing
  • Include expect.hasAssertions() at the start of each test
  • Test memoization/function reference stability
  • Verify cleanup on unmount
  • Test SSR compatibility where applicable
  • Cover edge cases, error handling, and performance scenarios

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:
- Use @testing-library/react-hooks for hook testing
- Include expect.hasAssertions() at the start of each test
- Test memoization/function reference stability
- Verify cleanup on unmount
- Test SSR compatibility where applicable
- Cover edge cases, error handling, and performance scenarios
@codesandbox
Copy link

codesandbox bot commented Nov 19, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@netlify
Copy link

netlify bot commented Nov 19, 2025

Deploy Preview for rooksjs ready!

Name Link
🔨 Latest commit f752da1
🔍 Latest deploy log https://app.netlify.com/projects/rooksjs/deploys/691ea30a4e1778000881af9f
😎 Deploy Preview https://deploy-preview-1882--rooksjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@vercel
Copy link

vercel bot commented Nov 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
rooks Ready Ready Preview Comment Nov 20, 2025 5:13am

Fix TypeScript compilation errors in hook tests:

- useGlobalObjectEventListener.spec.tsx: Add all 6 required parameters
  (globalObject, eventName, callback, listenerOptions, when, isLayoutEffect)
  to all function calls to satisfy the function overload signatures

- useMergeRefs.spec.tsx: Fix callback ref return types - callbacks must
  return void or cleanup function, not numbers. Changed arrow functions
  from implicit return of array.push() to explicit void return

All tests still pass (126 passing, 1 skipped)
Typecheck now passes successfully
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants