test(RadioGroup): improve

This commit is contained in:
Benjamin Canac
2024-05-29 14:41:23 +02:00
parent dfc63b1bc0
commit ff77967fd7
2 changed files with 42 additions and 13 deletions

View File

@@ -13,21 +13,23 @@ describe('RadioGroup', () => {
{ value: '3', label: 'Option 3' }
]
const props = { items }
it.each([
['with items', { props: { items } }],
['with defaultValue', { props: { items, defaultValue: '1' } }],
['with disabled', { props: { items, disabled: true } }],
['with items', { props }],
['with defaultValue', { props: { ...props, defaultValue: '1' } }],
['with disabled', { props: { ...props, disabled: true } }],
['with description', { props: { items: items.map((opt, count) => ({ ...opt, description: `Description ${count}` })) } }],
['with required', { props: { items, legend: 'Legend', required: true } }],
...sizes.map((size: string) => [`with size ${size}`, { props: { items, size } }]),
...colors.map((color: string) => [`with color ${color}`, { props: { items, color } }]),
['with class', { props: { items, class: 'absolute' } }],
['with ui', { props: { ui: { items, wrapper: 'ms-4' } } }],
['with orientation', { props: { items, orientation: 'horizontal' } }],
['with required', { props: { ...props, legend: 'Legend', required: true } }],
...sizes.map((size: string) => [`with size ${size}`, { props: { ...props, size } }]),
...colors.map((color: string) => [`with color ${color}`, { props: { ...props, color } }]),
['with class', { props: { ...props, class: 'absolute' } }],
['with ui', { props: { ...props, ui: { wrapper: 'ms-4' } } }],
['with orientation', { props: { ...props, orientation: 'horizontal' } }],
// Slots
['with legend slot', { props: { items }, slots: { label: () => 'Legend slot' } }],
['with label slot', { props: { items }, slots: { label: () => 'Label slot' } }],
['with description slot', { props: { items }, slots: { label: () => 'Description slot' } }]
['with legend slot', { props, slots: { label: () => 'Legend slot' } }],
['with label slot', { props, slots: { label: () => 'Label slot' } }],
['with description slot', { props, slots: { label: () => 'Description slot' } }]
])('renders %s correctly', async (nameOrHtml: string, options: { props?: RadioGroupProps<any>, slots?: Partial<RadioGroupSlots<any>> }) => {
const html = await ComponentRender(nameOrHtml, options, RadioGroup)
expect(html).toMatchSnapshot()