mirror of
https://github.com/selfxyz/self.git
synced 2026-01-09 14:48:06 -05:00
* 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
72 lines
2.3 KiB
JavaScript
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),
|
|
},
|
|
};
|
|
});
|