mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-25 17:30:37 +01:00
feat(Checkbox): new component (#67)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
32
test/components/Checkbox.spec.ts
Normal file
32
test/components/Checkbox.spec.ts
Normal 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()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user