From 8fe567d0e03e062fb98dba029b16cb2c1ad256be Mon Sep 17 00:00:00 2001 From: Ralf Eisele Date: Sat, 2 Mar 2024 08:57:20 +0100 Subject: [PATCH] adding select component test for required validiation with value=false --- .../rules/__tests__/validateRequired.test.ts | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/process/validation/rules/__tests__/validateRequired.test.ts b/src/process/validation/rules/__tests__/validateRequired.test.ts index 8e62bdf6..fe3ae4e8 100644 --- a/src/process/validation/rules/__tests__/validateRequired.test.ts +++ b/src/process/validation/rules/__tests__/validateRequired.test.ts @@ -3,7 +3,7 @@ import { expect } from 'chai'; import { FieldError } from 'error'; import { validateRequired } from '../validateRequired'; -import { conditionallyHiddenRequiredHiddenField, hiddenRequiredField, requiredNonInputField, simpleTextField, simpleSelectBoxes } from './fixtures/components'; +import { conditionallyHiddenRequiredHiddenField, hiddenRequiredField, requiredNonInputField, simpleTextField, simpleSelectBoxes, simpleRadioField } from './fixtures/components'; import { processOne } from 'processes/processOne'; import { generateProcessContext } from './fixtures/util'; import { ProcessorsContext, ValidationScope } from 'types'; @@ -26,6 +26,24 @@ it('Validating a simple component that is required and present in the data will expect(result).to.equal(null); }); + +it('Validating a simple radio component that is required and present in the data with value=false will return null', async () => { + const component = { ...simpleRadioField, validate: { required: true }, values: [ + { + label: 'Yes', + value: 'true', + }, + { + label: 'No', + value: 'false', + }] }; + const data = { component: false }; + const context = generateProcessContext(component, data); + const result = await validateRequired(context); + expect(result).to.equal(null); +}); + + it('Validating a simple selectbox that is required and present in the data with value=0 will return null', async () => { const component = { ...simpleSelectBoxes, validate: { required: true }, values: [ {