import React from 'react'; import { render, cleanup } from '@testing-library/react'; import '@testing-library/jest-dom/extend-expect'; import { Collapse } from '../index'; afterEach(cleanup); test('should take a snapshot', () => { const { asFragment } = render(); expect(asFragment()).toMatchSnapshot(); }); describe('Tests Collapse with and without children', () => { test('renders a Collapse without children', () => { const { getByTestId } = render( ); expect(getByTestId('collapse-id')).toBeInTheDocument(); }); test('renders a Collapse with children', () => { const { getByTestId } = render(

Child Content

); expect(getByTestId('collapse-id')).toBeInTheDocument(); expect(getByTestId('collapse-id')).toContainElement( getByTestId('child-id') ); }); });