/** * External dependencies */ import { render, fireEvent } from '@testing-library/react'; import '@testing-library/jest-dom'; /** * Internal dependencies */ import { WelcomeModal } from '../index'; import { recordEvent } from 'lib/tracks'; jest.mock( 'lib/tracks', () => ( { recordEvent: jest.fn() } ) ); describe( 'WelcomeModal', () => { it( 'should call onClose when it is closed', () => { const onCloseSpy = jest.fn(); const { queryAllByRole } = render( ); fireEvent.click( queryAllByRole( 'button' )[ 0 ] ); expect( onCloseSpy ).toHaveBeenCalledTimes( 1 ); } ); it( 'should not render the guide after it is closed', () => { const { queryAllByRole, container } = render( {} } /> ); fireEvent.click( queryAllByRole( 'button' )[ 0 ] ); expect( container ).toBeEmptyDOMElement(); } ); it( 'should track open and close', () => { const { queryAllByRole } = render( {} } /> ); expect( recordEvent ).toHaveBeenLastCalledWith( 'task_list_welcome_modal_open' ); fireEvent.click( queryAllByRole( 'button' )[ 0 ] ); expect( recordEvent ).toHaveBeenLastCalledWith( 'task_list_welcome_modal_close' ); } ); } );