-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathindex.test.tsx
More file actions
121 lines (102 loc) · 3.27 KB
/
Copy pathindex.test.tsx
File metadata and controls
121 lines (102 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/* eslint-disable import-x/no-nodejs-modules */
import React from 'react';
import { View } from 'react-native';
import Main from './';
import renderWithProvider from '../../../util/test/renderWithProvider';
import initialRootState from '../../../util/test/initial-root-state';
const mockReact = React;
const mockView = View;
// Mock Ramp shell to avoid deep dependency graph in Main mount test
jest.mock('../../../components/UI/Ramp', () => ({
__esModule: true,
default: () => mockReact.createElement('RampOrdersMock'),
}));
jest.mock('react-native-device-info', () => ({
getVersion: jest.fn(() => '0.0.0'),
getBuildNumber: jest.fn(() => '0'),
getUniqueId: jest.fn(() => 'test-device-id'),
getDeviceId: jest.fn(() => 'test-device-id'),
}));
// Mock heavy child components to avoid deep dependency issues
jest.mock('./MainNavigator', () => {
const MockMainNavigator = () =>
mockReact.createElement(mockView, { testID: 'mocked-main-navigator' });
MockMainNavigator.router = {};
return {
__esModule: true,
default: MockMainNavigator,
};
});
jest.mock(
'../../UI/GlobalAlert',
() => () => mockReact.createElement('GlobalAlertMock'),
);
jest.mock(
'../../UI/FadeOutOverlay',
() => () => mockReact.createElement('FadeOutOverlayMock'),
);
jest.mock(
'../../UI/Notification',
() => () => mockReact.createElement('NotificationMock'),
);
jest.mock('../../UI/Card/sdk', () => ({
CardVerification: () => null,
CardSDKProvider: ({ children }: { children: React.ReactNode }) => children,
}));
jest.mock(
'../../UI/Earn/components/EarnTransactionMonitor',
() => () => mockReact.createElement('EarnTransactionMonitorMock'),
);
jest.mock(
'../../UI/Money/components/MoneyTransactionMonitor/MoneyTransactionMonitor',
() => () => mockReact.createElement('MoneyTransactionMonitorMock'),
);
jest.mock('../../UI/ProtectYourWalletModal', () => ({
__esModule: true,
default: () => mockReact.createElement('ProtectYourWalletModalMock'),
}));
jest.mock('./RootRPCMethodsUI', () => ({
__esModule: true,
default: () => mockReact.createElement('RootRPCMethodsUIMock'),
}));
jest.mock(
'../../Views/ProtectWalletMandatoryModal/ProtectWalletMandatoryModal',
() => ({
__esModule: true,
default: () => mockReact.createElement('ProtectWalletMandatoryModalMock'),
}),
);
jest.mock(
'../../Views/Notifications/PushNotificationOnboarding/PushNotificationOnboardingRoot',
() => ({
__esModule: true,
default: () =>
mockReact.createElement('PushNotificationOnboardingRootMock'),
}),
);
jest.mock('../../UI/ReviewModal', () => ({
__esModule: true,
default: () => mockReact.createElement('ReviewModalMock'),
}));
jest.mock('../../../util/transaction-controller', () => ({
updateIncomingTransactions: jest.fn(),
startIncomingTransactionPolling: jest.fn(),
stopIncomingTransactionPolling: jest.fn(),
}));
describe('Main', () => {
beforeEach(() => {
jest.clearAllMocks();
});
it('mounts the main flow with mocked navigator and shell components', () => {
const { getByTestId } = renderWithProvider(<Main />, {
state: {
...initialRootState,
user: {
...initialRootState.user,
isConnectionRemoved: false,
},
},
});
expect(getByTestId('mocked-main-navigator')).toBeOnTheScreen();
});
});