use vitest each

This commit is contained in:
Peter Clement 2024-03-06 11:57:45 +00:00
parent eb00ce401f
commit 1f107041a1
1 changed files with 8 additions and 15 deletions

View File

@ -209,16 +209,19 @@ describe("runLuceneQuery", () => {
} }
) )
it("should return matching results if allOr is true and only one filter matches", () => { test.each([
[false, []],
[true, [1, 2, 3]],
])("should return %s if allOr is %s ", (allOr, expectedResult) => {
const query = buildQuery({ const query = buildQuery({
allOr: true, allOr,
oneOf: { staff_id: [10] }, oneOf: { staff_id: [10] },
contains: { description: ["box"] }, contains: { description: ["box"] },
}) })
expect(runLuceneQuery(docs, query).map(row => row.order_id)).toEqual([ expect(runLuceneQuery(docs, query).map(row => row.order_id)).toEqual(
1, 2, 3, expectedResult
]) )
}) })
it("should return matching results if allOr is true and only one filter matches with different operands", () => { it("should return matching results if allOr is true and only one filter matches with different operands", () => {
@ -231,16 +234,6 @@ describe("runLuceneQuery", () => {
expect(runLuceneQuery(docs, query).map(row => row.order_id)).toEqual([1, 2]) expect(runLuceneQuery(docs, query).map(row => row.order_id)).toEqual([1, 2])
}) })
it("should return nothing if allOr is false and only one filter matches", () => {
const query = buildQuery({
allOr: false,
oneOf: { staff_id: [10] },
contains: { description: ["box"] },
})
expect(runLuceneQuery(docs, query).map(row => row.order_id)).toEqual([])
})
it("should handle when a value is null or undefined", () => { it("should handle when a value is null or undefined", () => {
const query = buildQuery({ const query = buildQuery({
allOr: true, allOr: true,