import { press, click, act, render, screen, testA11y } from '@fuels/jest'; import { Button } from '../Button'; import { Dialog } from './Dialog'; import type { DialogProps } from './defs'; function Content(props: Omit) { return ( Dialog Title Just a big text with a nice description here ); } describe('Dialog', () => { it('a11y', async () => { await testA11y(); }); it('should open and close dialog correctly', async () => { const onOpen = jest.fn(); render(); const trigger = screen.getByText('Open'); expect(() => screen.getByText('Dialog Title')).toThrow(); await act(() => click(trigger)); expect(await screen.findByText('Dialog Title')).toBeInTheDocument(); expect(onOpen).toBeCalledTimes(1); await press('Esc'); expect(() => screen.getByText('Dialog Title')).toThrow(); }); it('should open by default without trigger', async () => { render(); expect(await screen.findByText('Dialog Title')).toBeInTheDocument(); }); });