import { render, screen } from '@testing-library/react'; import { WizardHeader } from '../WizardHeader'; import userEvent from '@testing-library/user-event'; // close button related tests test(`Renders close button by default`, () => { render(); expect(screen.getByRole('button')).toBeInTheDocument(); }); test(`Close button is hidden when isCloseHidden is passed`, () => { render(); expect(screen.queryByRole('button')).toBeNull(); }); test(`Close button renders passed aria label`, () => { render(); expect(screen.getByRole('button', { name: 'test aria label' })).toBeInTheDocument(); }); test(`Callback function fires when onClose passed`, async () => { const onClose = jest.fn(); const user = userEvent.setup(); render(); await user.click(screen.getByRole('button')); expect(onClose).toHaveBeenCalled(); }); // description related tests test(`Renders a description when passed description`, () => { render(); expect(screen.getByText('test description')).toBeVisible(); }); test(`Renders the id passed via descriptionId`, () => { render(); expect(screen.queryByText('test description')).toHaveAttribute('id', 'test-id'); }); // other prop tests test(`Renders title when prop is passed`, () => { render(); expect(screen.getByText('Test')).toBeVisible(); }); test(`Renders with additional classes when className is passed`, () => { render(); expect(screen.getByTestId('header-component')).toHaveClass('custom-class'); });