-
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
base: feature/MOB-12159-add-tests-for-useappstatelistener
Are you sure you want to change the base?
[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()); |
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(); |
Copilot uses AI. Check for mistakes.
}); | ||
|
||
act(() => { | ||
rerender(() => 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.
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.
Copilot uses AI. Check for mistakes.
}); | ||
|
||
act(() => { | ||
rerender(() => 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.
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.
Copilot uses AI. Check for mistakes.
}); | ||
|
||
act(() => { | ||
rerender(() => 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.
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.
Copilot uses AI. Check for mistakes.
|
||
// WHEN component re-renders with same dimensions | ||
act(() => { | ||
rerender(() => 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.
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.
Copilot uses AI. Check for mistakes.
}); | ||
|
||
act(() => { | ||
rerender(() => 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.
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.
Copilot uses AI. Check for mistakes.
}); | ||
|
||
act(() => { | ||
rerender(() => 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.
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.
Copilot uses AI. Check for mistakes.
🔹 JIRA Ticket(s) if any
✏️ Description
add unit tests for useDeviceOrientation