import React from 'react' import { render, screen, waitFor } from '@testing-library/react' import userEvent from '@testing-library/user-event' import { vi } from 'vitest' import { NavigationTab, type CustomNavigationTabProps } from './NavigationTabs' import styles from './NavigationTabs.module.scss' const user = userEvent.setup() const CustomComponent = (props: CustomNavigationTabProps): JSX.Element => ( ) describe('NavigationTabs', () => { it('renders a link', () => { const text = 'I am navigation tabs' const href = 'www.cultureamp.com' render() expect( screen.getByRole('link', { name: text, }), ).toBeInTheDocument() expect( screen.getByRole('link', { name: text, }), ).toHaveAttribute('href', href) }) describe('with a render prop', () => { it('renders the component passed with the navigation tab props', async () => { const handleClick = vi.fn() const text = 'I am also navigation tabs' const href = 'www.cultureamp.com' render( , ) const button = screen.getByRole('button', { name: `${href} - ${text} - true`, }) expect(button).toHaveClass(styles.linkAnchor, styles.active, styles.lightBackground) await user.click(button) await waitFor(() => { expect(handleClick).toBeCalledTimes(1) }) }) }) })