Skip to content
Snippets Groups Projects
Unverified Commit c41641cd authored by Ariya Hidayat's avatar Ariya Hidayat Committed by GitHub
Browse files

#13175 Repro: Can not do arithmetic in filter expressions (#14155)

parent b2edb459
No related branches found
No related tags found
No related merge requests found
import { parse } from "metabase/lib/expressions/parser";
describe("metabase/lib/expressions/parser", () => {
describe("in aggregation mode", () => {
function parseAggregation(source) {
const tokenVector = null;
const startRule = "aggregation";
return parse({ source, tokenVector, startRule });
}
it("should handle a simple aggregation", () => {
expect(() => parseAggregation("Sum([Price])")).not.toThrow();
});
it("should handle a conditional aggregation", () => {
expect(() => parseAggregation("CountIf( [Discount] > 0 )")).not.toThrow();
});
it.skip("should handle a complex conditional aggregation", () => {
expect(() =>
parseAggregation("CountIf( ( [Subtotal] + [Tax] ) > 100 )"),
).not.toThrow();
});
});
describe("in expression mode", () => {
function parseExpression(source) {
const tokenVector = null;
const startRule = "expression";
return parse({ source, tokenVector, startRule });
}
it("should handle a conditional using CASE", () => {
expect(() =>
parseExpression("Case( [Discount] > 0, 'Sale', 'Normal' )"),
).not.toThrow();
});
it.skip("should handle a complex conditional using CASE", () => {
expect(() =>
parseExpression("Case( [Price]-[Discount] > 50, 'Deal', 'Regular' )"),
).not.toThrow();
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment