test: improve

This commit is contained in:
Benjamin Canac
2024-04-25 11:53:15 +02:00
parent ebdaacfb9f
commit f48755f116
9 changed files with 158 additions and 63 deletions

View File

@@ -3,21 +3,23 @@ import Drawer, { type DrawerProps, type DrawerSlots } from '../../src/runtime/co
import ComponentRender from '../component-render'
describe('Drawer', () => {
const props = { open: true, portal: false }
it.each([
// Props
['with title', { props: { open: true, portal: false, title: 'Title' } }],
['with description', { props: { open: true, portal: false, title: 'Title', description: 'Description' } }],
['without overlay', { props: { open: true, portal: false, overlay: false, title: 'Title', description: 'Description' } }],
['with class', { props: { open: true, portal: false, class: 'bg-gray-50 dark:bg-gray-800' } }],
['with ui', { props: { open: true, portal: false, ui: { handle: 'w-20' } } }],
['with title', { props: { ...props, title: 'Title' } }],
['with description', { props: { ...props, title: 'Title', description: 'Description' } }],
['without overlay', { props: { ...props, overlay: false, title: 'Title', description: 'Description' } }],
['with class', { props: { ...props, class: 'bg-gray-50 dark:bg-gray-800' } }],
['with ui', { props: { ...props, ui: { handle: 'w-20' } } }],
// Slots
['with default slot', { props: { open: true, portal: false }, slots: { default: () => 'Default slot' } }],
['with content slot', { props: { open: true, portal: false }, slots: { content: () => 'Content slot' } }],
['with header slot', { props: { open: true, portal: false }, slots: { header: () => 'Header slot' } }],
['with title slot', { props: { open: true, portal: false }, slots: { title: () => 'Title slot' } }],
['with description slot', { props: { open: true, portal: false }, slots: { description: () => 'Description slot' } }],
['with body slot', { props: { open: true, portal: false }, slots: { body: () => 'Body slot' } }],
['with footer slot', { props: { open: true, portal: false }, slots: { footer: () => 'Footer slot' } }]
['with default slot', { props, slots: { default: () => 'Default slot' } }],
['with content slot', { props, slots: { content: () => 'Content slot' } }],
['with header slot', { props, slots: { header: () => 'Header slot' } }],
['with title slot', { props, slots: { title: () => 'Title slot' } }],
['with description slot', { props, slots: { description: () => 'Description slot' } }],
['with body slot', { props, slots: { body: () => 'Body slot' } }],
['with footer slot', { props, slots: { footer: () => 'Footer slot' } }]
])('renders %s correctly', async (nameOrHtml: string, options: { props?: DrawerProps, slots?: Partial<DrawerSlots> }) => {
const html = await ComponentRender(nameOrHtml, options, Drawer)
expect(html).toMatchSnapshot()