fix: Extension being too eager and making calls when it shouldn't (#5232)

fix: extension being too eager and making calls when it shouldn't
This commit is contained in:
Valya
2023-01-24 12:04:50 +00:00
committed by GitHub
parent 832fb87954
commit 09bdd96d29
2 changed files with 43 additions and 68 deletions

View File

@@ -98,6 +98,16 @@ describe('tmpl Expression Parser', () => {
});
});
describe('Edge cases', () => {
test("Nested member access with name of function inside a function doesn't result in function call", () => {
expect(evaluate('={{ Math.floor([1, 2, 3, 4].length + 10) }}')).toEqual(14);
expect(extendTransform('Math.floor([1, 2, 3, 4].length + 10)')?.code).toBe(
'extend(Math, "floor", [[1, 2, 3, 4].length + 10])',
);
});
});
describe('Non dot extensions', () => {
test('min', () => {
expect(evaluate('={{ min(1, 2, 3, 4, 5, 6) }}')).toEqual(1);