UNPKG

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

Version:

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

26 lines (25 loc) 1.03 kB
import React from 'react'; import { cleanup, fireEvent, render, screen } from '@testing-library/react-native'; import { ErrorMessageBox } from 'src/components'; import { Provider as PaperProvider } from 'react-native-paper'; describe('ErrorMessageBox Test', () => { const onClose = jest.fn(); const defaultProps = { title: 'Error Title', errorMessage: 'Error Message', onClose, }; const renderer = (props = defaultProps) => render(React.createElement(PaperProvider, null, React.createElement(ErrorMessageBox, Object.assign({}, props)))); afterEach(cleanup); it('renders correctly', () => { renderer(); expect(render).toBeTruthy(); }); it('should call onDismiss prop, when button is pressed', () => { renderer(); expect(screen.getByTestId('blui-error-message-box-close-icon')).toBeOnTheScreen(); fireEvent.press(screen.getByTestId('blui-error-message-box-close-icon')); expect(onClose).toHaveBeenCalled(); }); });