diff --git a/src/features/saveToGroup/useValidateGroupIsEmpty.ts b/src/features/saveToGroup/useValidateGroupIsEmpty.ts index 2fd34803fc..a6eb8b66d1 100644 --- a/src/features/saveToGroup/useValidateGroupIsEmpty.ts +++ b/src/features/saveToGroup/useValidateGroupIsEmpty.ts @@ -37,7 +37,12 @@ export function useValidateGroupIsEmpty { expect(screen.getByRole('listitem')).toHaveTextContent('Du må fylle ut land'); }); + it('required validation should not show when values are selected and labels are stored in an array', async () => { + await render({ + component: { + showValidations: ['Required'], + required: true, + dataModelBindings: { + simpleBinding: { dataType: defaultDataTypeMock, field: 'value' }, + label: { dataType: defaultDataTypeMock, field: 'label' }, + }, + }, + options: twoOptions, + queries: { + fetchFormData: () => Promise.resolve({ value: 'norway,sweden', label: ['Norway', 'Sweden'] }), + }, + }); + + expect(getCheckbox({ name: 'Norway', isChecked: true })).toBeInTheDocument(); + expect(getCheckbox({ name: 'Sweden', isChecked: true })).toBeInTheDocument(); + expect(screen.queryByText('Du må fylle ut land')).not.toBeInTheDocument(); + }); + it('required validation should show for group', async () => { await render({ component: {