diff --git a/frontend/test/unit/lib/expressions/parser.spec.js b/frontend/test/unit/lib/expressions/parser.spec.js index b35b2763aeb76d9ea82b2ea89451c406bb584ad4..19be7d5aa4b5e7d5a1e60186bd9881b6acf36662 100644 --- a/frontend/test/unit/lib/expressions/parser.spec.js +++ b/frontend/test/unit/lib/expressions/parser.spec.js @@ -52,6 +52,10 @@ describe("lib/expressions/parser", () => { expect(compile("1 + 2 + 3 * 4 * 5", expressionOpts)).toEqual(["+", 1, 2, ["*", 3, 4, 5]]); }); + it("can handle negative number literals", () => { + expect(compile("1 + -1", expressionOpts)).toEqual(["+", 1, -1]); + }); + // quoted field name w/ a space in it it("can parse a field with quotes and spaces", () => { expect(compile("\"Toucan Sam\" + B", expressionOpts)).toEqual(["+", ['field-id', 10], ['field-id', 2]]); @@ -75,6 +79,10 @@ describe("lib/expressions/parser", () => { expect(compile("Sum(A)", aggregationOpts)).toEqual(["sum", ["field-id", 1]]); }); + it("can handle negative number literals in aggregations", () => { + expect(compile("-1 * Count", aggregationOpts)).toEqual(["*", -1, ["count"]]); + }); + it("can parse complex aggregation", () => { expect(compile("1 - Sum(A * 2) / Count", aggregationOpts)).toEqual(["-", 1, ["/", ["sum", ["*", ["field-id", 1], 2]], ["count"]]]); });