-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDisabledButton.test.tsx
More file actions
33 lines (29 loc) · 1.17 KB
/
DisabledButton.test.tsx
File metadata and controls
33 lines (29 loc) · 1.17 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
import React from 'react';
import { renderPage, getPropsWithNavigation } from '../../../utils/tests/helpers';
import { DisabledButton } from '../DisabledButton';
import { fireEvent } from 'react-native-testing-library';
describe('[Page] DisabledButton', () => {
const props = getPropsWithNavigation();
it('renders correctly', () => {
const page = renderPage(<DisabledButton {...props} />);
expect(page).toMatchSnapshot();
});
it('shows disabled confirm button while password is blank', () => {
const page = renderPage(<DisabledButton {...props} />);
const ConfirmButton = page.getByText('Confirm');
expect(ConfirmButton).toBeDisabled();
});
it('shows success message when password confirmed', () => {
// Given
const page = renderPage(<DisabledButton {...props} />);
const PasswordInput = page.getByPlaceholder('password');
const ConfirmButton = page.getByText('Confirm');
// When
fireEvent.changeText(PasswordInput, 'azertyuiop123');
expect(ConfirmButton).toBeEnabled();
fireEvent.press(ConfirmButton);
// Then
const SuccessMessage = page.queryByText('Password confirmed');
expect(SuccessMessage).toBeTruthy();
});
});