Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/unit/SignInBackButtonTest.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {render} from '@testing-library/react-native';

import type * as AppActions from '@libs/actions/App';

import SignInModal from '@pages/signin/SignInModal';
import type {SignInPageRef} from '@pages/signin/SignInPage';
import {SignInPage} from '@pages/signin/SignInPage';
Expand All @@ -16,6 +18,9 @@ jest.mock('@libs/Navigation/Navigation', () => ({
goBack: () => {
mockGoBack();
},
dismissModal: jest.fn(),
navigate: jest.fn(),
isNavigationReady: () => Promise.resolve(),
},
navigationRef: {
get current() {
Expand All @@ -24,6 +29,14 @@ jest.mock('@libs/Navigation/Navigation', () => ({
},
}));

// SignInModal fires a real OpenApp request on mount. The global fetch mock in jest/setup.ts resolves it,
// so `finallyData` merges IS_LOADING_APP: false, which re-runs the effect that dismisses the modal while
// the test is still running. Stubbing openApp keeps that async work out of this unit test.
jest.mock('@libs/actions/App', () => ({
...jest.requireActual<typeof AppActions>('@libs/actions/App'),
openApp: jest.fn(),
}));

// Record the callbacks handed to the hook so the test can replay them. Jest resolves the platform-neutral
// no-op variant, so the callbacks are never invoked for real here.
const mockUseAndroidBackButtonHandler = jest.fn((callback: () => boolean) => callback);
Expand Down
Loading