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,8 +3,16 @@ import Collapsible, { type CollapsibleProps, type CollapsibleSlots } from '../..
import ComponentRender from '../component-render'
describe('Collapsible', () => {
const props = { open: true }
it.each([
['with open', { props: { open: true }, slots: { default: () => 'Click me', content: () => 'Collapsible content' } }]
// Props
['with open', { props }],
['with class', { props: { ...props, class: 'space-y-2' } }],
['with ui', { props: { ...props, ui: { content: 'bg-gray-50 dark:bg-gray-800' } } }],
// Slots
['with default slot', { props, slots: { default: () => 'Default slot' } }],
['with content slot', { props, slots: { content: () => 'Content slot' } }]
])('renders %s correctly', async (nameOrHtml: string, options: { props?: CollapsibleProps, slots?: Partial<CollapsibleSlots> }) => {
const html = await ComponentRender(nameOrHtml, options, Collapsible)
expect(html).toMatchSnapshot()