import renderer from 'react-test-renderer'; import Accordion from './Accordion'; import IconButton from './IconButton'; import Text from './Text'; describe('Accordion', () => { test('renders the base correctly', () => { const tree = renderer.create().toJSON(); expect(tree).toMatchSnapshot(); }); test('renders a title correctly', () => { const tree = renderer.create().toJSON(); expect(tree).toMatchSnapshot(); }); test('renders content correctly', () => { const tree = renderer .create( Testing , ) .toJSON(); expect(tree).toMatchSnapshot(); }); test('renders an icon correctly', () => { const tree = renderer .create( Testing , ) .toJSON(); expect(tree).toMatchSnapshot(); }); test('renders a badge correctly', () => { const tree = renderer .create( Testing , ) .toJSON(); expect(tree).toMatchSnapshot(); }); test('renders an error correctly', () => { const tree = renderer .create( Testing , ) .toJSON(); expect(tree).toMatchSnapshot(); }); test('renders an icon button correctly', () => { const tree = renderer .create( {}} size="xs" /> } id="accordion-test" title="Testing" > Testing , ) .toJSON(); expect(tree).toMatchSnapshot(); }); test('validate data test id for icon', () => { const component = renderer.create( Testing , ).root; expect( component .findAll((element) => element.type === 'svg') .filter((node) => node.props['data-test-id'] === 'test-accordion-icon'), ).toHaveLength(1); expect( component .findAll((element) => element.type === 'div') .filter((node) => node.props['data-test-id'] === 'test-accordion-text'), ).toHaveLength(1); }); test('validate data test id for badge', () => { const component = renderer.create( Testing , ).root; expect( component .findAll((element) => element.type === 'span') .filter((node) => node.props['data-test-id'] === 'test-accordion-badge-text'), ).toHaveLength(1); }); });