import { createRef } from 'react'; import { render, screen } from '@testing-library/react'; import SearchGuide from './SearchGuide'; describe('SearchGuide', () => { 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.getByText('SearchGuideText').click(); expect(mockOnClick).toHaveBeenCalled(); }); it('renders a default searchguide with sequential keyboard navigation and forwards a ref to the innermost element', () => { const ref = createRef(); // @ts-expect-error - TS2322 - Type 'RefObject' is not assignable to type 'LegacyRef | undefined'. render(); expect(ref.current instanceof HTMLButtonElement).toEqual(true); expect(ref.current?.type).toEqual('button'); expect(ref.current instanceof HTMLButtonElement && ref.current?.tabIndex).toEqual(0); }); it('renders with data-test-id', () => { const TEST_ID = 'searchguide-test-123'; render(); expect( screen.getByTestId(TEST_ID, { exact: true, }), ).toBeVisible(); }); });