import React from 'react'; import { render, cleanup } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import { Modal } from './index'; jest.mock('../Portal'); let openTestValue = true; const closeTestValue = () => (openTestValue = false); afterEach(cleanup); test('should take a snapshot', () => { const { asFragment } = render( ); expect(asFragment()).toMatchSnapshot(); }); describe('Tests Modal', () => { test('with content', () => { const { getByTestId } = render(

It's modal content

); expect(getByTestId('modal-id')).toBeInTheDocument(); }); test('with open=false', () => { const { getByTestId } = render(
); expect(getByTestId('modal-wrapper-id')).toBeInTheDocument(); expect(getByTestId('modal-wrapper-id')).toContainHTML( '
' ); }); });