import { render } from '@testing-library/react'; import InfoList from '../info-list'; describe('InfoList component', () => { const infoData = [ { title: 'Item 1', content:
Some content
, }, { title: 'Another item', content:
Some more content
, }, ]; it('should render', () => { const { asFragment } = render(); expect(asFragment()).toMatchSnapshot(); }); it('should render nothing when empty list', () => { const { container } = render(); expect(container).toBeEmptyDOMElement(); }); it('should render nothing when no content', () => { const { container } = render( ); expect(container).toBeEmptyDOMElement(); }); it('should render compact', () => { const { asFragment } = render(); expect(asFragment()).toMatchSnapshot(); }); it('should render without titles', () => { const { asFragment } = render(); expect(asFragment()).toMatchSnapshot(); }); it('should render with titles in 2 columns', () => { const { asFragment } = render(); expect(asFragment()).toMatchSnapshot(); }); it('should not render items that are undefined', () => { const { asFragment } = render( ); expect(asFragment()).toMatchSnapshot(); }); it('should render title that is a React Node', () => { const { asFragment } = render( Item 1, content:
Some content
}, ]} /> ); expect(asFragment()).toMatchSnapshot(); }); });