-
Notifications
You must be signed in to change notification settings - Fork 39
[MOB-12160] add unit tests for useDeviceOrientation #708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MOB-12160] add unit tests for useDeviceOrientation #708
Conversation
|
Diff Coverage: Not applicable. There was no coverage data reported for the files in this diff. Total Coverage: This PR will increase coverage by 1.07%. File Coverage Changes
🛟 Help
This is from Qlty Cloud, the successor to Code Climate Quality. Learn more. |
…to feature/MOB-12160-add-tests-for-usedeviceorientation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds comprehensive unit tests for the useDeviceOrientation hook to improve test coverage and ensure the hook behaves correctly across various scenarios.
Key changes:
- Added 424 lines of unit tests covering initial state, orientation changes, edge cases, hook behavior, and type safety
- Tests verify portrait/landscape detection logic based on height vs width comparison
- Includes edge case testing for zero, negative, and decimal dimensions
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| }); | ||
|
|
||
| act(() => { | ||
| rerender(() => useDeviceOrientation()); |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rerender callback should not recreate the hook function on each call. Pass the existing hook result or use rerender({}) to trigger a re-render without recreating the hook.
| rerender(() => useDeviceOrientation()); | |
| rerender(); |
| }); | ||
|
|
||
| act(() => { | ||
| rerender(() => useDeviceOrientation()); |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rerender callback should not recreate the hook function on each call. Pass the existing hook result or use rerender({}) to trigger a re-render without recreating the hook.
| }); | ||
|
|
||
| act(() => { | ||
| rerender(() => useDeviceOrientation()); |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rerender callback should not recreate the hook function on each call. Pass the existing hook result or use rerender({}) to trigger a re-render without recreating the hook.
| }); | ||
|
|
||
| act(() => { | ||
| rerender(() => useDeviceOrientation()); |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rerender callback should not recreate the hook function on each call. Pass the existing hook result or use rerender({}) to trigger a re-render without recreating the hook.
|
|
||
| // WHEN component re-renders with same dimensions | ||
| act(() => { | ||
| rerender(() => useDeviceOrientation()); |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rerender callback should not recreate the hook function on each call. Pass the existing hook result or use rerender({}) to trigger a re-render without recreating the hook.
| }); | ||
|
|
||
| act(() => { | ||
| rerender(() => useDeviceOrientation()); |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rerender callback should not recreate the hook function on each call. Pass the existing hook result or use rerender({}) to trigger a re-render without recreating the hook.
| }); | ||
|
|
||
| act(() => { | ||
| rerender(() => useDeviceOrientation()); |
Copilot
AI
Oct 7, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rerender callback should not recreate the hook function on each call. Pass the existing hook result or use rerender({}) to trigger a re-render without recreating the hook.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite sure I understand the Why behind this to its extent, but looks like orientation testing with intention of whether the hooks are getting called correctly adn veriyfing the dimensions is the approach here.
Looks good to me. Just never saw the negative dimensions before 😅. But could be the case for RN
🔹 JIRA Ticket(s) if any
✏️ Description
add unit tests for useDeviceOrientation