1
0
Fork 0
mirror of synced 2024-09-09 22:16:26 +12:00

Make sure we're treating AUTO as numbers.

This commit is contained in:
Sam Rose 2024-04-25 16:51:42 +01:00
parent 8b2156ed08
commit b07db7b098
No known key found for this signature in database

View file

@ -61,7 +61,10 @@ describe.each([
}
async function createRows(rows: Record<string, any>[]) {
await config.api.row.bulkImport(table._id!, { rows })
// await config.api.row.bulkImport(table._id!, { rows })
for (const row of rows) {
await config.api.row.save(table._id!, row)
}
}
class SearchAssertion {
@ -689,7 +692,7 @@ describe.each([
subtype: AutoFieldSubType.AUTO_ID,
},
})
await createRows([{}, {}, {}])
await createRows(new Array(10).fill({}))
})
describe("equal", () => {
@ -705,6 +708,13 @@ describe.each([
expectQuery({ notEqual: { auto: 1 } }).toContainExactly([
{ auto: 2 },
{ auto: 3 },
{ auto: 4 },
{ auto: 5 },
{ auto: 6 },
{ auto: 7 },
{ auto: 8 },
{ auto: 9 },
{ auto: 10 },
]))
it("fails to find nonexistent row", () =>
@ -712,6 +722,13 @@ describe.each([
{ auto: 1 },
{ auto: 2 },
{ auto: 3 },
{ auto: 4 },
{ auto: 5 },
{ auto: 6 },
{ auto: 7 },
{ auto: 8 },
{ auto: 9 },
{ auto: 10 },
]))
})
@ -747,8 +764,8 @@ describe.each([
isSqs &&
it("can search using just a low value", () =>
expectQuery({
range: { auto: { low: 2 } },
}).toContainExactly([{ auto: 2 }, { auto: 3 }]))
range: { auto: { low: 9 } },
}).toContainExactly([{ auto: 9 }, { auto: 10 }]))
isSqs &&
it("can search using just a high value", () =>
@ -756,5 +773,43 @@ describe.each([
range: { auto: { high: 2 } },
}).toContainExactly([{ auto: 1 }, { auto: 2 }]))
})
describe("sort", () => {
it("sorts ascending", () =>
expectSearch({
query: {},
sort: "auto",
sortOrder: SortOrder.ASCENDING,
}).toMatchExactly([
{ auto: 1 },
{ auto: 2 },
{ auto: 3 },
{ auto: 4 },
{ auto: 5 },
{ auto: 6 },
{ auto: 7 },
{ auto: 8 },
{ auto: 9 },
{ auto: 10 },
]))
it("sorts descending", () =>
expectSearch({
query: {},
sort: "auto",
sortOrder: SortOrder.DESCENDING,
}).toMatchExactly([
{ auto: 10 },
{ auto: 9 },
{ auto: 8 },
{ auto: 7 },
{ auto: 6 },
{ auto: 5 },
{ auto: 4 },
{ auto: 3 },
{ auto: 2 },
{ auto: 1 },
]))
})
})
})