Skip to content

Commit

Permalink
Add more complex tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zoriya committed Dec 22, 2024
1 parent df52b01 commit 5f0e180
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions api/tests/misc/filter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,51 @@ describe("Parse filter", () => {
},
});
});
it("Handle or", () => {
const ret = parse(
"not rating lt 10 and rating lt 20 or (status eq finished and not status ne airing)",
);
expect(ret).toMatchObject({
ok: true,
value: {
type: "or",
lhs: {
type: "and",
lhs: {
type: "not",
expression: {
type: "op",
operator: "lt",
property: "rating",
value: { type: "int", value: 10 },
},
},
rhs: {
type: "op",
operator: "lt",
property: "rating",
value: { type: "int", value: 20 },
},
},
rhs: {
type: "and",
lhs: {
type: "op",
operator: "eq",
property: "status",
value: { type: "enum", value: "finished" },
},
rhs: {
type: "not",
expression: {
type: "op",
operator: "ne",
property: "status",
value: { type: "enum", value: "airing" },
},
},
},
},
});
});
});

0 comments on commit 5f0e180

Please sign in to comment.