import { render, screen } from '@testing-library/react'; import { WizardNavItem } from '../WizardNavItem'; import styles from '@patternfly/react-styles/css/components/Wizard/wizard'; import userEvent from '@testing-library/user-event'; test(`Renders with additional classes when className is passed`, () => { render(); expect(screen.getByRole('listitem')).toHaveClass('custom-class'); }); test(`Renders content passed to content prop`, () => { render(); expect(screen.getByText('test content')).toBeVisible(); }); test(`Renders ${styles.modifiers.disabled} class when isDisabled is true`, () => { render(); expect(screen.getByRole('button')).toHaveClass(styles.modifiers.disabled); }); test(`Renders ${styles.modifiers.current} class when isCurrent is true`, () => { render(); expect(screen.getByRole('button')).toHaveClass(styles.modifiers.current); }); test(`Callback function fires when onClick passed`, async () => { const onClick = jest.fn(); const user = userEvent.setup(); render(); await user.click(screen.getByRole('button')); expect(onClick).toHaveBeenCalled(); }); test(`Renders a link element with an href when the props are passed`, () => { render(); expect(screen.getByRole('link')).toHaveAttribute('href', 'test-href'); }); test(`Renders a link element with a target when the props are passed`, () => { render(); expect(screen.getByRole('link')).toHaveAttribute('target', 'test-target'); }); test(`Renders an expandable li when isExapandable is passed`, () => { render(); expect(screen.getByRole('button')).toHaveAttribute('aria-expanded', 'false'); expect(screen.getByRole('listitem')).toHaveClass(styles.modifiers.expandable); }); test(`Renders id to nav item button when passed`, () => { render(); expect(screen.getByRole('button')).toHaveAttribute('id', 'test-id'); }); test(`Renders screen reader text and danger icon when status is error`, () => { render(); expect(screen.getByRole('button')).toHaveClass(styles.modifiers.danger); expect(screen.getByText(', error')).toBeInTheDocument(); }); test(`Renders screen reader text and success icon when status is success`, () => { render(); expect(screen.getByRole('button')).toHaveClass(styles.modifiers.success); expect(screen.getByText(', success')).toBeInTheDocument(); }); test(`Renders screen reader text and warning icon when status is warning`, () => { render(); expect(screen.getByRole('button')).toHaveClass(styles.modifiers.warning); expect(screen.getByText(', warning')).toBeInTheDocument(); });