test(react-utils): add initial version of useSticky test suite#682
test(react-utils): add initial version of useSticky test suite#682adamsoderstrom wants to merge 3 commits intofix/use-sticky-viewport-containerfrom
useSticky test suite#682Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 5247d1c The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
useSticky test suite
56678b2 to
cf50542
Compare
There was a problem hiding this comment.
Pull request overview
Fixes useSticky’s fallback stickiness boundary so that when no container is provided it uses viewport dimensions (matching IntersectionObserver’s default root behavior), and introduces an initial test suite for the hook.
Changes:
- Adjust
useStickyboundary-rect logic to fall back to a viewportDOMRectwhen no container is available. - Add a new
useStickytest suite covering disabled behavior, observer margin calculation, stickiness transitions, and custom container behavior. - Add a changeset describing the behavioral fix.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/react-utils/src/useSticky.ts | Aligns fallback stickiness boundary with viewport when container is not provided. |
| packages/react-utils/src/useSticky.test.ts | Adds initial unit tests for useSticky behavior and container handling. |
| .changeset/rare-dancers-beam.md | Documents the behavioral change for a patch release. |
| .changeset/orange-insects-hide.md | Adds an empty changeset file (currently contains no release info). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## fix/use-sticky-viewport-container #682 +/- ##
=====================================================================
+ Coverage 67.86% 72.48% +4.62%
=====================================================================
Files 63 63
Lines 974 974
Branches 246 246
=====================================================================
+ Hits 661 706 +45
+ Misses 254 204 -50
- Partials 59 64 +5 see 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
maeertin
left a comment
There was a problem hiding this comment.
thought: Some tests, although valid, perhaps test the actual implementation too much when we might want to keep testing to checking the returned values from the hook. For example in the case of const { result } = renderHook(() => useSticky(ref, [options]) we want to test that result gives back what we want.
On the other hand, we might not get around testing like without simulating actual user scrolling.
No description provided.