From ff77967fd7883f91cc5b04ed743420cbaecf84c4 Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Wed, 29 May 2024 14:41:23 +0200 Subject: [PATCH] test(RadioGroup): improve --- test/components/RadioGroup.spec.ts | 26 +++++++++-------- .../__snapshots__/RadioGroup.spec.ts.snap | 29 ++++++++++++++++++- 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/test/components/RadioGroup.spec.ts b/test/components/RadioGroup.spec.ts index 842e79d9..08aeb186 100644 --- a/test/components/RadioGroup.spec.ts +++ b/test/components/RadioGroup.spec.ts @@ -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, slots?: Partial> }) => { const html = await ComponentRender(nameOrHtml, options, RadioGroup) expect(html).toMatchSnapshot() diff --git a/test/components/__snapshots__/RadioGroup.spec.ts.snap b/test/components/__snapshots__/RadioGroup.spec.ts.snap index b3a6027b..d21922eb 100644 --- a/test/components/__snapshots__/RadioGroup.spec.ts.snap +++ b/test/components/__snapshots__/RadioGroup.spec.ts.snap @@ -665,9 +665,36 @@ exports[`RadioGroup > renders with size xs correctly 1`] = ` `; exports[`RadioGroup > renders with ui correctly 1`] = ` -"
+"
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
" `;