feat(design): add IMS Admin primitives (Button, StatusTag, Checkbox, FilterChip, Segmented, Avatar, Drawer) and restyle Field, Card, Modal
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,49 +2,27 @@ import { describe, it, expect, vi } from 'vitest'
|
||||
import { render, screen, fireEvent } from '@testing-library/react'
|
||||
import { Modal } from '@/components/ui/modal'
|
||||
|
||||
describe('Modal (Modernist dialog)', () => {
|
||||
describe('Modal', () => {
|
||||
it('renders nothing when closed', () => {
|
||||
const { container } = render(
|
||||
<Modal open={false} onClose={() => {}} title="T">
|
||||
body
|
||||
</Modal>,
|
||||
)
|
||||
const { container } = render(<Modal open={false} onClose={() => {}} title="T">body</Modal>)
|
||||
expect(container.firstChild).toBeNull()
|
||||
})
|
||||
|
||||
it('renders a dialog with title, body and footer on the surface fill', () => {
|
||||
render(
|
||||
<Modal open onClose={() => {}} title="Confirm" footer={<span>actions</span>}>
|
||||
body text
|
||||
</Modal>,
|
||||
)
|
||||
it('renders a 12px card dialog with the floating shadow and a 1px header rule', () => {
|
||||
render(<Modal open onClose={() => {}} title="Confirm" footer={<span>actions</span>}>body text</Modal>)
|
||||
const dialog = screen.getByRole('dialog')
|
||||
expect(dialog).toBeTruthy()
|
||||
expect(screen.getByText('Confirm')).toBeTruthy()
|
||||
expect(screen.getByText('body text')).toBeTruthy()
|
||||
expect(screen.getByText('actions')).toBeTruthy()
|
||||
expect(dialog.innerHTML).toContain('bg-surface')
|
||||
expect(dialog.innerHTML).toContain('shadow-lg')
|
||||
})
|
||||
|
||||
it('has no rounded corners and uses a 2px title rule', () => {
|
||||
render(
|
||||
<Modal open onClose={() => {}} title="T">
|
||||
x
|
||||
</Modal>,
|
||||
)
|
||||
const html = screen.getByRole('dialog').innerHTML
|
||||
expect(html).not.toMatch(/rounded/)
|
||||
expect(html).toContain('border-b')
|
||||
expect(dialog.innerHTML).toContain('rounded-xl')
|
||||
expect(dialog.innerHTML).toContain('shadow-float')
|
||||
expect(dialog.innerHTML).toContain('border-b border-rule')
|
||||
expect(dialog.innerHTML).not.toContain('border-b-2')
|
||||
})
|
||||
|
||||
it('closes from the X button and on Escape', () => {
|
||||
const onClose = vi.fn()
|
||||
render(
|
||||
<Modal open onClose={onClose} title="T">
|
||||
x
|
||||
</Modal>,
|
||||
)
|
||||
render(<Modal open onClose={onClose} title="T">x</Modal>)
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Close' }))
|
||||
fireEvent.keyDown(document, { key: 'Escape' })
|
||||
expect(onClose).toHaveBeenCalledTimes(2)
|
||||
|
||||
Reference in New Issue
Block a user