Skip to content

Conversation

lposen
Copy link
Contributor

@lposen lposen commented Oct 3, 2025

🔹 JIRA Ticket(s) if any

✏️ Description

add unit tests for useDeviceOrientation

Copy link

github-actions bot commented Oct 3, 2025

Lines Statements Branches Functions
Coverage: 48%
48.41% (229/473) 20.67% (37/179) 41.29% (64/155)

Copy link

qltysh bot commented Oct 3, 2025

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
Path File Coverage Δ Indirect
src/core/hooks/useDeviceOrientation.tsx 100.0
🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

This is from Qlty Cloud, the successor to Code Climate Quality. Learn more.

@lposen lposen changed the title [MOB-12159] add unit tests for useDeviceOrientation [MOB-12160] add unit tests for useDeviceOrientation Oct 6, 2025
…to feature/MOB-12160-add-tests-for-usedeviceorientation
@lposen lposen requested a review from Copilot October 7, 2025 01:50
Copy link

@Copilot Copilot AI left a 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());
Copy link
Preview

Copilot AI Oct 7, 2025

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.

Suggested change
rerender(() => useDeviceOrientation());
rerender();

Copilot uses AI. Check for mistakes.

});

act(() => {
rerender(() => useDeviceOrientation());
Copy link
Preview

Copilot AI Oct 7, 2025

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());
Copy link
Preview

Copilot AI Oct 7, 2025

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());
Copy link
Preview

Copilot AI Oct 7, 2025

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());
Copy link
Preview

Copilot AI Oct 7, 2025

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());
Copy link
Preview

Copilot AI Oct 7, 2025

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());
Copy link
Preview

Copilot AI Oct 7, 2025

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.

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.

1 participant