Skip to content

Conversation

lposen
Copy link
Contributor

@lposen lposen commented Oct 3, 2025

🔹 JIRA Ticket(s) if any

✏️ Description

Add tests for useAppStateListener

Copy link

github-actions bot commented Oct 3, 2025

Lines Statements Branches Functions
Coverage: 47%
47.45% (224/472) 20.67% (37/179) 40% (62/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 8.89%.

File Coverage Changes
Path File Coverage Δ Indirect
src/core/classes/Iterable.ts 22.5
src/core/classes/IterableAuthResponse.ts 100.0
src/core/hooks/useAppStateListener.ts 100.0
src/hooks/index.ts -100.0
src/inApp/classes/IterableInAppMessage.ts 12.1
🛟 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.

…to feature/MOB-12159-add-tests-for-useappstatelistener
@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 test coverage for the useAppStateListener React Native hook, implementing unit tests to verify the hook's functionality including initial state handling, listener setup, state transitions, cleanup, and re-render behavior.

  • Adds complete test suite covering all app state transitions (active, background, inactive)
  • Tests proper setup and cleanup of AppState event listeners
  • Verifies re-render stability and state consistency

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +161 to +162
rerender(() => useAppStateListener());
rerender(() => useAppStateListener());
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 function expects no parameters, but arrow functions are being passed. This should be rerender() to trigger re-renders of the same hook.

Copilot uses AI. Check for mistakes.

expect(result.current).toBe('background');

// WHEN the component re-renders
rerender(() => useAppStateListener());
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 function expects no parameters, but an arrow function is being passed. This should be rerender() to trigger a re-render of the same hook.

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

Copilot uses AI. Check for mistakes.

Copy link
Member

@Ayyanchira Ayyanchira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Base automatically changed from feature/MOB-12158-improve-iterable-ts-test-coverage to master October 8, 2025 20:01
@lposen lposen merged commit b1decd7 into master Oct 8, 2025
8 of 9 checks passed
@lposen lposen deleted the feature/MOB-12159-add-tests-for-useappstatelistener branch October 8, 2025 20:02
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.

2 participants