-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.test.tsx
More file actions
76 lines (64 loc) · 2.08 KB
/
App.test.tsx
File metadata and controls
76 lines (64 loc) · 2.08 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
/**
* @format
*/
import React from 'react';
import App from '../App';
import { Transaction } from '@op-engineering/op-sqlite';
import { render, waitFor } from '@testing-library/react-native';
jest.mock('react-native-gesture-handler', () => ({
GestureHandlerRootView: ({ children }: { children: React.ReactNode }) =>
children,
gestureHandlerRootHOC: (comp: unknown) => comp,
State: {},
Directions: {},
}));
jest.mock('@react-navigation/native', () => ({
NavigationContainer: ({ children }: { children: React.ReactNode }) =>
children,
}));
jest.mock('@react-navigation/stack', () => ({
createStackNavigator: () => ({
Navigator: ({ children }: { children: React.ReactNode }) => children,
Screen: () => null,
}),
}));
jest.mock('@react-native-vector-icons/ionicons', () => ({
Ionicons: () => null,
}));
jest.mock('react-native-safe-area-context', () => ({
SafeAreaProvider: ({ children }: { children: React.ReactNode }) => children,
useSafeAreaInsets: () => ({ top: 0, bottom: 0, left: 0, right: 0 }),
}));
jest.mock('../src/assets/icons/fluent-logo.svg', () => 'FluentLogo');
jest.mock('../src/navigation/AppNavigator', () => {
const MockReact = require('react');
const { View } = require('react-native');
return () => MockReact.createElement(View, { testID: 'app-navigator' });
});
jest.mock('../src/services/fluent-api.test', () => ({
runApiIntegrationTest: jest.fn(() => Promise.resolve()),
}));
jest.mock('@op-engineering/op-sqlite', () => ({
open: jest.fn(() =>
Promise.resolve({
execute: jest.fn(),
transaction: jest.fn(async (fn: (tx: Transaction) => Promise<void>) =>
fn({
execute: jest.fn(),
} as unknown as Transaction),
),
}),
),
}));
jest.mock('../src/db/index', () => ({
initializeDatabase: jest.fn(() => Promise.resolve()),
}));
jest.mock('../src/services/sync', () => ({
syncAllData: jest.fn(() => Promise.resolve()),
}));
test('renders correctly', async () => {
const { getByTestId } = render(<App />);
await waitFor(() => {
expect(getByTestId('app-navigator')).toBeTruthy();
});
});