Skip to content

Commit

Permalink
tests(core): Write tests to allow intentional 0s to be validated
Browse files Browse the repository at this point in the history
  • Loading branch information
dana-gill committed Dec 27, 2024
1 parent 7b621a5 commit 2b43d3d
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,47 @@ describe('validateValueAgainstSchema', () => {
// value should be type number
expect(typeof result).toEqual('number');
});

test('should validate when the value to be validated is 0, the mode is in Fixed mode, and the node is a resource mapper', () => {
const nodeType = {
description: {
properties: [
{
name: 'operation',
type: 'resourceMapper',
typeOptions: {
resourceMapper: {
mode: 'add',
},
},
},
],
},
} as unknown as INodeType;

const node = {
parameters: {
operation: {
schema: [
{
id: 'num',
type: 'number',
required: true,
},
],
attemptToConvertTypes: true,
mappingMode: '',
value: '',
},
},
} as unknown as INode;

const value = { num: 0 };

const parameterName = 'operation.value';

expect(() =>
validateValueAgainstSchema(node, nodeType, value, parameterName, 0, 0),
).not.toThrow();
});
});

0 comments on commit 2b43d3d

Please sign in to comment.