UNPKG

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

Version:

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

25 lines (24 loc) 1.05 kB
import React from 'react'; import { cleanup, fireEvent, render, screen } from '@testing-library/react-native'; import { BasicDialog } from 'src/components'; import { Provider as PaperProvider } from 'react-native-paper'; describe('BasicDialog Test', () => { const renderer = (props) => render(React.createElement(PaperProvider, null, React.createElement(BasicDialog, Object.assign({}, props)))); afterEach(cleanup); const onDismiss = jest.fn(); it('renders correctly', () => { renderer(); expect(render).toBeTruthy(); }); it('should display the passed props', () => { renderer({ open: true, title: 'Dialog Title' }); expect(screen.getByText('Dialog Title')).toBeOnTheScreen(); }); it('should call onDismiss prop, when button is pressed', () => { renderer({ open: true, title: 'Dialog Title', onDismiss }); expect(screen.getByText('Okay')).toBeOnTheScreen(); fireEvent.press(screen.getByText('Okay')); expect(onDismiss).toHaveBeenCalled(); }); });