Skip to content
Merged
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: 11 additions & 2 deletions tests/unit/SignInBackButtonTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import SignInModal from '@pages/signin/SignInModal';
import type {SignInPageRef} from '@pages/signin/SignInPage';
import {SignInPage} from '@pages/signin/SignInPage';

import CONST from '@src/CONST';

import React, {createRef} from 'react';

const mockGoBack = jest.fn();
let mockCanGoBack = true;
const mockAnonymousAuthTokenType = CONST.AUTH_TOKEN_TYPES.ANONYMOUS;

jest.mock('@libs/Navigation/Navigation', () => ({
__esModule: true,
Expand All @@ -16,6 +19,8 @@ jest.mock('@libs/Navigation/Navigation', () => ({
goBack: () => {
mockGoBack();
},
dismissModal: jest.fn(),
navigate: jest.fn(),
},
navigationRef: {
get current() {
Expand Down Expand Up @@ -46,8 +51,12 @@ jest.mock('@pages/signin/SignUpWelcomeForm', () => 'SignUpWelcomeForm');
jest.mock('@components/ColorSchemeWrapper', () => 'ColorSchemeWrapper');
jest.mock('@components/CustomStatusBarAndBackground', () => 'CustomStatusBarAndBackground');

// SignInModal reads the session to decide when to dismiss itself. The back listener does not depend on it.
jest.mock('@components/OnyxListItemProvider', () => ({useSession: () => undefined}));
// SignInModal reads the session to decide when to dismiss itself, and treats any non anonymous session as signed
// in. Report the anonymous session that a rendered sign-in modal actually has, so the dismiss effect stays idle
// and does not call openApp. openApp writes IS_LOADING_APP asynchronously, which would otherwise dismiss the
// modal partway through the test. The back listener does not depend on the session.
// Read lazily: jest hoists this factory above the constant below.
jest.mock('@components/OnyxListItemProvider', () => ({useSession: () => ({authTokenType: mockAnonymousAuthTokenType})}));
jest.mock('@components/ScreenWrapper', () => 'ScreenWrapper');
jest.mock('@components/HeaderWithBackButton', () => 'HeaderWithBackButton');

Expand Down
Loading