1import { fireEvent, render, screen } from '@testing-library/react'; 2 3import { Collapsible } from '.'; 4 5describe(Collapsible, () => { 6 it('hides content by default', () => { 7 render(<Collapsible summary="Summary">Content</Collapsible>); 8 expect(screen.getByText('Summary')).toBeVisible(); 9 expect(screen.getByText('Content')).not.toBeVisible(); 10 }); 11 12 it('shows content when opened', () => { 13 render(<Collapsible summary="Summary">Content</Collapsible>); 14 fireEvent.click(screen.getByText('Summary')); 15 expect(screen.getByText('Summary')).toBeVisible(); 16 expect(screen.getByText('Content')).toBeVisible(); 17 }); 18 19 it('shows content when rendered with open', () => { 20 render( 21 <Collapsible summary="Summary" open> 22 Content 23 </Collapsible> 24 ); 25 expect(screen.getByText('Summary')).toBeVisible(); 26 expect(screen.getByText('Content')).toBeVisible(); 27 }); 28}); 29