Files
self/app/tests/__setup__/mocks/navigation.js
Justin Hernandez 202d0f8122 SELF-483: Enable backup recovery prompts (#834)
* Guard recovery prompts

* refactor(app): gate recovery prompts with allow list (#1251)

* fix typing

* fix header

* fix app loading

* fix tests

* Limit recovery prompts to home allowlist (#1460)

* fix test

* fix typing pipeline

* format and fix linting and tests

* tests pass

* fix tests

* split up testing

* save wip

* save button fix

* fix count

* fix modal width

* remove consologging

* remove depcrecated login count

* linting

* lint

* early return
2025-12-05 21:34:50 -08:00

72 lines
2.3 KiB
JavaScript

// SPDX-FileCopyrightText: 2025 Social Connect Labs, Inc.
// SPDX-License-Identifier: BUSL-1.1
// NOTE: Converts to Apache-2.0 on 2029-06-11 per LICENSE.
// Grouped navigation mocks to avoid cluttering jest.setup.js
jest.mock('@react-navigation/native', () => {
// Avoid nested requireActual to prevent OOM in CI
// Create mock navigator without requiring React
const MockNavigator = (props, _ref) => props.children;
MockNavigator.displayName = 'MockNavigator';
return {
useFocusEffect: jest.fn(callback => {
// Immediately invoke the effect for testing without requiring a container
return callback();
}),
useNavigation: jest.fn(() => ({
navigate: jest.fn(),
goBack: jest.fn(),
canGoBack: jest.fn(() => true),
dispatch: jest.fn(),
getState: jest.fn(() => ({ routes: [{ name: 'Home' }], index: 0 })),
})),
useRoute: jest.fn(() => ({
key: 'mock-route-key',
name: 'MockRoute',
params: {},
})),
useIsFocused: jest.fn(() => true),
useLinkTo: jest.fn(() => jest.fn()),
createNavigationContainerRef: jest.fn(() => global.mockNavigationRef),
createStaticNavigation: jest.fn(() => MockNavigator),
NavigationContainer: ({ children }) => children,
DefaultTheme: {},
DarkTheme: {},
};
});
jest.mock('@react-navigation/native-stack', () => ({
createNativeStackNavigator: jest.fn(config => config),
createNavigatorFactory: jest.fn(),
}));
// Mock core navigation to avoid requiring a NavigationContainer for hooks
jest.mock('@react-navigation/core', () => {
// Avoid nested requireActual to prevent OOM in CI
return {
useNavigation: jest.fn(() => ({
navigate: jest.fn(),
goBack: jest.fn(),
canGoBack: jest.fn(() => true),
dispatch: jest.fn(),
getState: jest.fn(() => ({ routes: [{ name: 'Home' }], index: 0 })),
})),
useRoute: jest.fn(() => ({
key: 'mock-route-key',
name: 'MockRoute',
params: {},
})),
useIsFocused: jest.fn(() => true),
useLinkTo: jest.fn(() => jest.fn()),
NavigationContext: {
Provider: ({ children }) => children,
Consumer: ({ children }) => children(null),
},
NavigationRouteContext: {
Provider: ({ children }) => children,
Consumer: ({ children }) => children(null),
},
};
});