feat(Checkbox): new component (#67)

Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
Romain Hamel
2024-03-27 12:00:15 +01:00
committed by GitHub
parent 8fd369372b
commit bfd5988358
34 changed files with 718 additions and 303 deletions

View File

@@ -0,0 +1,32 @@
import { describe, it, expect } from 'vitest'
import { UCheckbox } from '#components'
import type { TypeOf } from 'zod'
import ComponentRender from '../component-render'
import { defu } from 'defu'
describe('Checkbox', () => {
it.each([
['basic case', {}],
['with label', { props: { label: 'Label' } }],
['with slot', { slots: { default: () => 'Label slot' } }],
['with slot label', { slots: { label: () => 'Label slot' } }],
['with custom id', { props: { id: 'custom-id' } }],
['with custom value', { props: { value: 'custom-value' } }],
['with custom name', { props: { name: 'custom-name' } }],
['with disabled', { props: { disabled: true } }],
['with indeterminate', { props: { indeterminate: true } }],
['with help', { props: { label: 'Label', help: 'Help' } }],
['with required', { props: { label: 'Label', required: true } }],
['with custom color', { props: { label: 'Label', color: 'red' } }],
['with size 2xs', { props: { size: '2xs' as const } }],
['with size xs', { props: { size: 'xs' as const } }],
['with size sm', { props: { size: 'sm' as const } }],
['with size md', { props: { size: 'md' as const } }],
['with size lg', { props: { size: 'lg' as const } }],
['with size xl', { props: { size: 'xl' as const } }]
// @ts-ignore
])('renders %s correctly', async (nameOrHtml: string, options: TypeOf<typeof UCheckbox.props>) => {
const html = await ComponentRender(nameOrHtml, defu(options, { props: { id: 42 } }), UCheckbox)
expect(html).toMatchSnapshot()
})
})