mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-30 03:38:54 +01:00
feat(RadioGroup): new component (#41)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
This commit is contained in:
32
test/components/RadioGroup.spec.ts
Normal file
32
test/components/RadioGroup.spec.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import RadioGroup, { type RadioGroupProps } from '../../src/runtime/components/RadioGroup.vue'
|
||||
import ComponentRender from '../component-render'
|
||||
import { defu } from 'defu'
|
||||
|
||||
const defaultOptions = [
|
||||
{ value: '1', label: 'Option 1' },
|
||||
{ value: '2', label: 'Option 2' },
|
||||
{ value: '3', label: 'Option 3' }
|
||||
]
|
||||
|
||||
describe('RadioGroup', () => {
|
||||
it.each([
|
||||
['basic case', {}],
|
||||
['with default value', { props: { defaultValue: '1' } }],
|
||||
['with disabled', { props: { disabled: true } }],
|
||||
['with description', { props: { options: defaultOptions.map((opt, count) => ({ ...opt, description: `Description ${count}` })) } }],
|
||||
['with required', { props: { legend: 'Legend', required: true } }],
|
||||
['with custom color', { props: { color: 'red' as const } }],
|
||||
['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 } }],
|
||||
['with class', { props: { class: 'bg-red-500' } }],
|
||||
['with ui', { props: { ui: {} } }]
|
||||
])('renders %s correctly', async (nameOrHtml: string, options: { props?: RadioGroupProps<any>, slots?: any }) => {
|
||||
const html = await ComponentRender(nameOrHtml, defu(options, { props: { options: defaultOptions } }), RadioGroup)
|
||||
expect(html).toMatchSnapshot()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user