-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathAesCryptoTestForm.test.tsx
More file actions
61 lines (49 loc) · 1.77 KB
/
AesCryptoTestForm.test.tsx
File metadata and controls
61 lines (49 loc) · 1.77 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
import React from 'react';
import { render, fireEvent } from '@testing-library/react-native';
import { strings } from '../../../../locales/i18n';
import AesCryptoTestForm from './AesCryptoTestForm';
import {
aesCryptoFormHeader,
aesCryptoFormHeaderBackButton,
aesCryptoFormSafeArea,
} from './AesCrypto.testIds';
const mockGoBack = jest.fn();
jest.mock('react-redux', () => ({
...jest.requireActual('react-redux'),
useSelector: jest.fn(),
}));
jest.mock('@react-navigation/native', () => {
const actualReactNavigation = jest.requireActual('@react-navigation/native');
return {
...actualReactNavigation,
useNavigation: () => ({
navigate: jest.fn(),
setOptions: jest.fn(),
goBack: mockGoBack,
}),
};
});
describe('AesCryptoTestForm', () => {
beforeEach(() => {
mockGoBack.mockClear();
});
it('wraps content in SafeAreaView from react-native-safe-area-context', () => {
const { getByTestId } = render(<AesCryptoTestForm />);
const safeArea = getByTestId(aesCryptoFormSafeArea);
expect(safeArea).toBeOnTheScreen();
expect(safeArea.props.edges).toMatchObject({ bottom: 'additive' });
});
it('renders HeaderStandard with title and back button', () => {
const { getByTestId, getByText } = render(<AesCryptoTestForm />);
expect(getByTestId(aesCryptoFormHeader)).toBeOnTheScreen();
expect(
getByText(strings('app_settings.aes_crypto_test_form_title')),
).toBeOnTheScreen();
expect(getByTestId(aesCryptoFormHeaderBackButton)).toBeOnTheScreen();
});
it('calls navigation.goBack when header back button is pressed', () => {
const { getByTestId } = render(<AesCryptoTestForm />);
fireEvent.press(getByTestId(aesCryptoFormHeaderBackButton));
expect(mockGoBack).toHaveBeenCalledTimes(1);
});
});