@brightlayer-ui/react-native-auth-workflow
Version:
Re-usable workflow components for Authentication and Registration within Eaton applications.
41 lines (40 loc) • 2.1 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { render, cleanup, screen, fireEvent } from '@testing-library/react-native';
import { ChangePasswordScreenBase } from '../../screens/ChangePasswordScreen/index.js';
import { SafeAreaProvider } from 'react-native-safe-area-context';
//
afterEach(cleanup);
describe('Change Password Screen Base', () => {
const currentPasswordChange = jest.fn();
const renderer = () => render(_jsx(SafeAreaProvider, { children: _jsx(ChangePasswordScreenBase, { WorkflowCardHeaderProps: { title: 'Change Password' }, currentPasswordLabel: "Current Password", currentPasswordChange: currentPasswordChange, PasswordProps: {
onPasswordChange: () => { },
newPasswordLabel: 'New Password',
initialNewPasswordValue: '',
confirmPasswordLabel: 'Confirm Password',
initialConfirmPasswordValue: '',
passwordRequirements: [],
passwordRef: undefined,
confirmRef: undefined,
onSubmit: function () {
throw new Error('Function not implemented.');
},
} }) }));
it('renders without crashing', () => {
expect(renderer).toBeTruthy();
});
it('should display the password fields', () => {
renderer();
const currentPasswordInput = screen.getAllByText('Current Password')[0];
const passwordInput = screen.getByTestId('blui-set-password-password-text-field');
const confirmInput = screen.getByTestId('blui-set-password-confirm-password-text-field');
expect(currentPasswordInput).toBeOnTheScreen();
expect(passwordInput).toBeOnTheScreen();
expect(confirmInput).toBeOnTheScreen();
});
it('input onChange callBack', () => {
renderer();
const currentPasswordInput = screen.getByTestId('blui-change-password-current-password-text-field');
fireEvent.changeText(currentPasswordInput, 'Password@123A');
expect(currentPasswordInput).toHaveDisplayValue('Password@123A');
});
});