Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanbond committed Mar 25, 2024
1 parent 2ab83df commit cfc72b4
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/process/validation/rules/__tests__/validateJson.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,32 @@ it('A simple component with JSON logic evaluation will return null if the JSON l
const result = await validateJson(context);
expect(result).to.equal(null);
});

it('A simple component with JSON logic evaluation will validate even if the value is falsy', async () => {
const component = {
...simpleTextField,
validate: {
json: {
if: [
{
'===': [
{
var: 'input',
},
'foo',
],
},
true,
"Input must be 'foo'",
],
},
},
};
const data = {
component: '',
};
const context = generateProcessorContext(component, data);
const result = await validateJson(context);
expect(result).to.be.instanceOf(FieldError);
expect(result?.errorKeyOrMessage).to.contain("Input must be 'foo'");
});

0 comments on commit cfc72b4

Please sign in to comment.