UNPKG

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

Version:

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

37 lines (36 loc) 2.06 kB
import React from 'react'; // import '@testing-library/jest-dom'; import { cleanup, render, fireEvent, screen } from '@testing-library/react-native'; import { SafeAreaProvider } from 'react-native-safe-area-context'; import { CreateAccountScreenBase } from '../../screens/CreateAccountScreen'; afterEach(cleanup); describe('Create Account Base', () => { it('renders correctly', () => { render(React.createElement(SafeAreaProvider, null, React.createElement(CreateAccountScreenBase, null))); expect(screen.getByTestId('blui-create-account-email-text-input')).toBeOnTheScreen(); }); it('renders correctly with props', () => { render(React.createElement(SafeAreaProvider, null, React.createElement(CreateAccountScreenBase, { WorkflowCardInstructionProps: { instructions: 'Test Instructions' }, initialValue: "a", emailValidator: (email) => { if ((email === null || email === void 0 ? void 0 : email.length) > 6) { return true; } return 'Please enter a valid email'; } }))); expect(screen.getByText('Please enter a valid email')).toBeOnTheScreen(); }); it('email textinput onchange works correctly', () => { const updateInput = jest.fn(); const { getByTestId } = render(React.createElement(SafeAreaProvider, null, React.createElement(CreateAccountScreenBase, { WorkflowCardInstructionProps: { instructions: 'Test Instructions' }, initialValue: "a", emailValidator: (email) => { if ((email === null || email === void 0 ? void 0 : email.length) > 6) { return true; } return 'Please enter a valid email'; }, emailTextFieldProps: { onChangeText: updateInput } }))); const Input = getByTestId('blui-create-account-email-text-input'); fireEvent.changeText(Input, 'email@test.com'); expect(updateInput).toHaveBeenCalledTimes(1); }); });