import React from 'react'; import { render } from '@testing-library/react'; import { ModalOverlay } from './modal-overlay'; describe('ModalOverlay', () => { it('should render ModalOverlay without error', () => { const { getByTestId } = render( , ); expect(getByTestId('modal-overlay')).toBeDefined(); expect(getByTestId('modal-overlay')).toHaveClass('mm-modal-overlay'); }); it('should match snapshot', () => { const { container } = render(); expect(container).toMatchSnapshot(); }); it('should render with and additional className', () => { const { getByTestId } = render( , ); expect(getByTestId('modal-overlay')).toHaveClass('test-class'); }); it('should fire the onClick function when clicked', () => { const onClick = jest.fn(); const { getByTestId } = render( , ); getByTestId('modal-overlay').click(); expect(onClick).toHaveBeenCalled(); }); });