diff --git a/src/process/validation/rules/__tests__/validateRequired.test.ts b/src/process/validation/rules/__tests__/validateRequired.test.ts index 878cc4af..8e62bdf6 100644 --- a/src/process/validation/rules/__tests__/validateRequired.test.ts +++ b/src/process/validation/rules/__tests__/validateRequired.test.ts @@ -2,7 +2,8 @@ import { expect } from 'chai'; import { FieldError } from 'error'; import { validateRequired } from '../validateRequired'; -import { conditionallyHiddenRequiredHiddenField, hiddenRequiredField, requiredNonInputField, simpleTextField } from './fixtures/components'; + +import { conditionallyHiddenRequiredHiddenField, hiddenRequiredField, requiredNonInputField, simpleTextField, simpleSelectBoxes } from './fixtures/components'; import { processOne } from 'processes/processOne'; import { generateProcessContext } from './fixtures/util'; import { ProcessorsContext, ValidationScope } from 'types'; @@ -25,16 +26,32 @@ it('Validating a simple component that is required and present in the data will expect(result).to.equal(null); }); -it('Validating a simple component that is required and present in the data with value=0 will return null', async () => { - const component = { ...simpleTextField, validate: { required: true } }; +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: [ + { + label: 'true', + value: 'true', + }, + { + label: 'Null', + value: '0', + }] }; const data = { component: 0 }; const context = generateProcessContext(component, data); const result = await validateRequired(context); expect(result).to.equal(null); }); -it('Validating a simple component that is required and present in the data with value=false will return null', async () => { - const component = { ...simpleTextField, validate: { required: true } }; +it('Validating a simple selectbox that is required and present in the data with value=false will return null', async () => { + const component = { ...simpleSelectBoxes, validate: { required: true }, values: [ + { + label: 'true', + value: 'true', + }, + { + label: 'false', + value: 'false', + }] }; const data = { component: false }; const context = generateProcessContext(component, data); const result = await validateRequired(context);