import { createRef } from 'react'; import { render, screen } from '@testing-library/react'; import IconButton from './IconButton'; describe('IconButton', () => { it('renders with icon', () => { const { container } = render(); expect(container).toMatchSnapshot(); }); it('renders with disabled state', () => { const { container } = render(); expect(container).toMatchSnapshot(); }); it('renders with svg', () => { const { container } = render( , ); expect(container).toMatchSnapshot(); }); it('renders with tooltip', () => { const { container } = render( , ); expect(container).toMatchSnapshot(); }); it('renders with tooltip and no accessibilityLabel', () => { const { container } = render( , ); expect(container).toMatchSnapshot(); }); it('renders with data-test-id', () => { const TEST_ID = 'button-test-123'; render(); expect( screen.getByTestId(TEST_ID, { exact: true, }), ).toBeVisible(); }); it('handles click', () => { const mockOnClick = jest.fn< [ { event: React.MouseEvent | React.KeyboardEvent; }, ], // @ts-expect-error - TS2344 - Type 'undefined' does not satisfy the constraint 'any[]'. undefined >(); render(); screen.getByRole('button').click(); expect(mockOnClick).toHaveBeenCalled(); }); it('renders a button with sequential keyboard navigation and forwards a ref to the innermost