UNPKG

@brightlayer-ui/react-native-auth-workflow

Version:

Re-usable workflow components for Authentication and Registration within Eaton applications.

56 lines (55 loc) 2.24 kB
import React from 'react'; import { cleanup, render, screen } from '@testing-library/react-native'; import { Provider as PaperProvider, Text } from 'react-native-paper'; import { ResetPasswordScreenBase } from '../../screens'; jest.useFakeTimers(); describe('ResetPasswordScreenBase tests', () => { const renderer = (props) => render(React.createElement(PaperProvider, null, React.createElement(ResetPasswordScreenBase, Object.assign({}, props)))); afterEach(cleanup); let mockFunction; beforeEach(() => { mockFunction = jest.fn(); }); afterEach(() => { jest.clearAllMocks(); }); it('renders without crashing', () => { renderer({ WorkflowCardHeaderProps: { title: 'Reset Password', }, }); expect(screen.getByText('Reset Password')).toBeTruthy(); }); it('should render success screen', () => { renderer({ showSuccessScreen: true, }); expect(screen.getByTestId('blui-workflow-card-action-divider')).toBeOnTheScreen(); }); it('should render passed props correctly', () => { renderer({ PasswordProps: { onPasswordChange: mockFunction(), newPasswordLabel: 'New Password', initialNewPasswordValue: 'New', confirmPasswordLabel: 'Confirm New Password', initialConfirmPasswordValue: 'Confirm New', passwordNotMatchError: 'wrong entries', }, }); expect(screen.getAllByText('New Password')).toBeTruthy(); expect(screen.getByTestId('blui-set-password-password-text-field').props.value).toBe('New'); expect(screen.getAllByText('Confirm New Password')).toBeTruthy(); expect(screen.getByTestId('blui-set-password-confirm-password-text-field').props.value).toBe('Confirm New'); expect(screen.getByText('wrong entries')).toBeOnTheScreen(); }); it('should render success screen', () => { renderer({ showSuccessScreen: true, SuccessScreen: () => React.createElement(Text, null, "Test"), }); expect(screen.getByText('Test')).toBeOnTheScreen(); }); });