Skip to content

Commit

Permalink
adding select component test for required validiation with value=false
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfeis committed Mar 2, 2024
1 parent e8dcb0a commit 8fe567d
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/process/validation/rules/__tests__/validateRequired.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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: [
{
Expand Down

0 comments on commit 8fe567d

Please sign in to comment.