Add some tests to the variable resolver to ensure static JSON is properly evaluated (#9104)
This commit is contained in:
committed by
GitHub
parent
d0f7270c28
commit
f05a217f62
@ -74,4 +74,40 @@ describe('resolveInput', () => {
|
|||||||
|
|
||||||
expect(resolveInput(input, context)).toEqual(expected);
|
expect(resolveInput(input, context)).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not wrap string variables with double quotes', () => {
|
||||||
|
expect(
|
||||||
|
resolveInput('{ {{test}}: 2 }', {
|
||||||
|
test: 'prop',
|
||||||
|
}),
|
||||||
|
).toBe('{ prop: 2 }');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not modify static JSON', () => {
|
||||||
|
expect(resolveInput('{ "a": 2 }', {})).toBe('{ "a": 2 }');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('supports variable as JSON object property name', () => {
|
||||||
|
expect(
|
||||||
|
resolveInput('{ "{{test}}": 2 }', {
|
||||||
|
test: 'prop',
|
||||||
|
}),
|
||||||
|
).toBe('{ "prop": 2 }');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('supports variable as JSON number value', () => {
|
||||||
|
expect(
|
||||||
|
resolveInput('{ "a": {{test}} }', {
|
||||||
|
test: 2,
|
||||||
|
}),
|
||||||
|
).toBe('{ "a": 2 }');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('supports variable as JSON string value', () => {
|
||||||
|
expect(
|
||||||
|
resolveInput('{ "a": "{{test}}" }', {
|
||||||
|
test: 'str',
|
||||||
|
}),
|
||||||
|
).toBe('{ "a": "str" }');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user