-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathHome.test.tsx
31 lines (26 loc) · 858 Bytes
/
Home.test.tsx
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
import React from 'react';
import {
cleanup,
render,
screen,
userEvent,
} from '@testing-library/react-native';
import App from '../App';
afterEach(cleanup);
//mocking async storage module
const mockedSetItem = jest.fn();
jest.mock('@react-native-community/async-storage', () => ({
setItem: mockedSetItem,
}));
jest.useFakeTimers();
it('renders/navigates throughout app screens', async () => {
// Render the app from teh root
render(<App />);
// Check whether we're in the home screen
expect(screen.getByText(/home/i)).toBeOnTheScreen();
// Navigate to counter screen by pressing on button
const user = userEvent.setup();
await user.press(screen.getByText(/counter/i));
// Check that navigation was succeeded by inspecting corresponding text on the screen
expect(screen.getByText(/current count: 0/i)).toBeOnTheScreen();
});