import * as React from 'react'; import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { ExpandableSection, ExpandableSectionVariant } from '../ExpandableSection'; import { ExpandableSectionToggle } from '../ExpandableSectionToggle'; const props = {}; test('ExpandableSection', () => { const { asFragment } = render(test ); expect(asFragment()).toMatchSnapshot(); }); test('Renders ExpandableSection expanded', () => { const { asFragment } = render( test ); expect(asFragment()).toMatchSnapshot(); }); test('ExpandableSection onToggle called', async () => { const mockfn = jest.fn(); const user = userEvent.setup(); render( test ); await user.click(screen.getByRole('button')); expect(mockfn.mock.calls).toHaveLength(1); }); test('Renders Uncontrolled ExpandableSection', () => { const { asFragment } = render( test ); expect(asFragment()).toMatchSnapshot(); }); test('Detached ExpandableSection renders successfully', () => { const { asFragment } = render( test Toggle text ); expect(asFragment()).toMatchSnapshot(); }); test('Disclosure ExpandableSection', () => { const { asFragment } = render( test{' '} ); expect(asFragment()).toMatchSnapshot(); }); test('Renders ExpandableSection indented', () => { const { asFragment } = render( {' '} test{' '} ); expect(asFragment()).toMatchSnapshot(); }); test('Does not render with pf-m-truncate class when variant is not passed', () => { render(test); expect(screen.getByText('test').parentElement).not.toHaveClass('pf-m-truncate'); }); test('Does not render with pf-m-truncate class when variant is not truncate', () => { render( test ); expect(screen.getByText('test').parentElement).not.toHaveClass('pf-m-truncate'); }); test('Renders with pf-m-truncate class when variant is truncate', () => { render( test ); expect(screen.getByText('test').parentElement).toHaveClass('pf-m-truncate'); });