mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 20:19:34 +01:00
feat: uniformize components sizes (#68)
This commit is contained in:
@@ -1,35 +1,34 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { defu } from 'defu'
|
||||
import RadioGroup, { type RadioGroupProps } from '../../src/runtime/components/RadioGroup.vue'
|
||||
import ComponentRender from '../component-render'
|
||||
|
||||
const defaultOptions = [
|
||||
{ value: '1', label: 'Option 1' },
|
||||
{ value: '2', label: 'Option 2' },
|
||||
{ value: '3', label: 'Option 3' }
|
||||
]
|
||||
import theme from '#build/ui/radio-group'
|
||||
|
||||
describe('RadioGroup', () => {
|
||||
const sizes = Object.keys(theme.variants.size) as any
|
||||
const colors = Object.keys(theme.variants.color) as any
|
||||
|
||||
const options = [
|
||||
{ value: '1', label: 'Option 1' },
|
||||
{ value: '2', label: 'Option 2' },
|
||||
{ value: '3', label: 'Option 3' }
|
||||
]
|
||||
|
||||
it.each([
|
||||
['basic case', {}],
|
||||
['with class', { props: { class: 'absolute' } }],
|
||||
['with ui', { props: { ui: { wrapper: 'ms-4' } } }],
|
||||
['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 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 legend slot', { slots: { label: () => 'Legend slot' } }],
|
||||
['with label slot', { slots: { label: () => 'Label slot' } }],
|
||||
['with options', { props: { options } }],
|
||||
['with defaultValue', { props: { options, defaultValue: '1' } }],
|
||||
['with disabled', { props: { options, disabled: true } }],
|
||||
['with description', { props: { options: options.map((opt, count) => ({ ...opt, description: `Description ${count}` })) } }],
|
||||
['with required', { props: { options, legend: 'Legend', required: true } }],
|
||||
...sizes.map((size: string) => [`with size ${size}`, { props: { options, size } }]),
|
||||
...colors.map((color: string) => [`with color ${color}`, { props: { options, color } }]),
|
||||
['with class', { props: { options, class: 'absolute' } }],
|
||||
['with ui', { props: { ui: { options, wrapper: 'ms-4' } } }],
|
||||
// Slots
|
||||
['with legend slot', { props: { options }, slots: { label: () => 'Legend slot' } }],
|
||||
['with label slot', { props: { options }, slots: { label: () => 'Label slot' } }],
|
||||
['with description slot', { slots: { label: () => 'Description slot' } }]
|
||||
])('renders %s correctly', async (nameOrHtml: string, options: { props?: RadioGroupProps<any>, slots?: any }) => {
|
||||
const html = await ComponentRender(nameOrHtml, defu(options, { props: { options: defaultOptions } }), RadioGroup)
|
||||
const html = await ComponentRender(nameOrHtml, options, RadioGroup)
|
||||
expect(html).toMatchSnapshot()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user