import '@testing-library/jest-dom' import { cleanup, render } from '@testing-library/react' import { axe, toHaveNoViolations } from 'jest-axe' import { createRef } from 'react' import { PktModal } from './Modal' expect.extend(toHaveNoViolations) afterEach(cleanup) describe('PktModal', () => { test('ref works correctly', () => { const ref = createRef() const { unmount } = render( modal content , ) expect(ref.current).toBeInstanceOf(HTMLDialogElement) unmount() expect(ref.current).toBeNull() }) test('renders with the specified size', () => { const { container } = render( modal content , ) const dialogElement = container.querySelector('dialog.pkt-modal') expect(dialogElement).toHaveClass('pkt-modal--small') }) test('renders with no wcag errors with axe', async () => { const { container } = render() const results = await axe(container) expect(results).toHaveNoViolations() }) test('renders with default props', () => { const { container } = render(innhold) const dialog = container.querySelector('dialog.pkt-modal') expect(dialog).toBeInTheDocument() expect(dialog).toHaveClass('pkt-modal--medium') }) })