import { render, screen } from '@testing-library/react'; import Dropdown from './Dropdown'; describe('Dropdown.Link', () => { const onClickMock = jest.fn< [ { dangerouslyDisableOnNavigation: () => void; event: React.MouseEvent | React.KeyboardEvent; mobileOnDismissStart: () => void; }, ], // @ts-expect-error - TS2344 - Type 'undefined' does not satisfy the constraint 'any[]'. undefined >(); test('calls onClick when Item clicked', () => { render( , ); screen.getByText('Item 4').click(); expect(onClickMock).toHaveBeenCalled(); }); test('creates an anchor when href is passed', () => { render( , ); // eslint-disable-next-line testing-library/no-node-access -- Please fix the next time this file is touched! expect(screen.getByText('Item 4').closest('a')).toHaveAttribute( 'href', 'https://www.pinterest.com', ); }); test('adds badge and external icon', () => { render( , ); expect(screen.getByRole('img', { hidden: true })).toBeInTheDocument(); // eslint-disable-next-line testing-library/prefer-presence-queries -- Please fix the next time this file is touched! expect(screen.queryByText('Beta Badge')).toBeInTheDocument(); expect( screen.queryByTitle(', Opens a new tab', { exact: true, }), ).not.toBeVisible(); }); test('adds avatar', () => { render( , ); expect(screen.getByAltText('Ayesha avatar')).toBeInTheDocument(); }); });