feat(ui): Dialog with backdrop + escape + motion fade

This commit is contained in:
Bastien Chanot committed 2026-05-18 21:18:18 +02:00
1 parent a1453ec32e
commit afd58b386b
2 files changed
+101 -2

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
import { describe, it, expect, vi } from 'vitest'
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import Dialog from '@/components/ui/Dialog'
describe('Dialog', () => {
it('renders nothing when open=false', () => {
render(
<Dialog open={false} onClose={() => {}} title="X">
body
</Dialog>,
)
expect(screen.queryByText('body')).toBeNull()
})
it('renders content when open=true', () => {
render(
<Dialog open={true} onClose={() => {}} title="X">
body
</Dialog>,
)
expect(screen.getByText('body')).toBeInTheDocument()
})
it('calls onClose on backdrop click', async () => {
const onClose = vi.fn()
render(
<Dialog open onClose={onClose} title="X">
body
</Dialog>,
)
await userEvent.click(screen.getByTestId('dialog-backdrop'))
expect(onClose).toHaveBeenCalled()
})
})