Add other tests
This commit is contained in:
parent
318dd5e628
commit
684e360715
|
@ -962,6 +962,7 @@ describe.each([
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
!isInternal &&
|
||||||
describe("datetime - time only", () => {
|
describe("datetime - time only", () => {
|
||||||
const T_1000 = "10:00"
|
const T_1000 = "10:00"
|
||||||
const T_1045 = "10:45"
|
const T_1045 = "10:45"
|
||||||
|
@ -969,6 +970,8 @@ describe.each([
|
||||||
const T_1530 = "15:30"
|
const T_1530 = "15:30"
|
||||||
const T_0000 = "00:00"
|
const T_0000 = "00:00"
|
||||||
|
|
||||||
|
const UNEXISTING_TIME = "10:01"
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await createTable({
|
await createTable({
|
||||||
time: { name: "time", type: FieldType.DATETIME, timeOnly: true },
|
time: { name: "time", type: FieldType.DATETIME, timeOnly: true },
|
||||||
|
@ -988,7 +991,117 @@ describe.each([
|
||||||
]))
|
]))
|
||||||
|
|
||||||
it("fails to find nonexistent row", () =>
|
it("fails to find nonexistent row", () =>
|
||||||
expectQuery({ equal: { time: "10:01" } }).toFindNothing())
|
expectQuery({ equal: { time: UNEXISTING_TIME } }).toFindNothing())
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("notEqual", () => {
|
||||||
|
it("successfully finds a row", () =>
|
||||||
|
expectQuery({ notEqual: { time: T_1000 } }).toContainExactly([
|
||||||
|
{ time: "10:45:00" },
|
||||||
|
{ time: "12:00:00" },
|
||||||
|
{ time: "15:30:00" },
|
||||||
|
{ time: "00:00:00" },
|
||||||
|
]))
|
||||||
|
|
||||||
|
it("return all when requesting non-existing", () =>
|
||||||
|
expectQuery({ notEqual: { time: UNEXISTING_TIME } }).toContainExactly(
|
||||||
|
[
|
||||||
|
{ time: "10:00:00" },
|
||||||
|
{ time: "10:45:00" },
|
||||||
|
{ time: "12:00:00" },
|
||||||
|
{ time: "15:30:00" },
|
||||||
|
{ time: "00:00:00" },
|
||||||
|
]
|
||||||
|
))
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("oneOf", () => {
|
||||||
|
it("successfully finds a row", () =>
|
||||||
|
expectQuery({ oneOf: { time: [T_1000] } }).toContainExactly([
|
||||||
|
{ time: "10:00:00" },
|
||||||
|
]))
|
||||||
|
|
||||||
|
it("fails to find nonexistent row", () =>
|
||||||
|
expectQuery({ oneOf: { time: [UNEXISTING_TIME] } }).toFindNothing())
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("range", () => {
|
||||||
|
it("successfully finds a row", () =>
|
||||||
|
expectQuery({
|
||||||
|
range: { time: { low: T_1045, high: T_1045 } },
|
||||||
|
}).toContainExactly([{ time: "10:45:00" }]))
|
||||||
|
|
||||||
|
it("successfully finds multiple rows", () =>
|
||||||
|
expectQuery({
|
||||||
|
range: { time: { low: T_1045, high: T_1530 } },
|
||||||
|
}).toContainExactly([
|
||||||
|
{ time: "10:45:00" },
|
||||||
|
{ time: "12:00:00" },
|
||||||
|
{ time: "15:30:00" },
|
||||||
|
]))
|
||||||
|
|
||||||
|
it("successfully finds no rows", () =>
|
||||||
|
expectQuery({
|
||||||
|
range: { time: { low: UNEXISTING_TIME, high: UNEXISTING_TIME } },
|
||||||
|
}).toFindNothing())
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("sort", () => {
|
||||||
|
it("sorts ascending", () =>
|
||||||
|
expectSearch({
|
||||||
|
query: {},
|
||||||
|
sort: "time",
|
||||||
|
sortOrder: SortOrder.ASCENDING,
|
||||||
|
}).toMatchExactly([
|
||||||
|
{ time: "00:00:00" },
|
||||||
|
{ time: "10:00:00" },
|
||||||
|
{ time: "10:45:00" },
|
||||||
|
{ time: "12:00:00" },
|
||||||
|
{ time: "15:30:00" },
|
||||||
|
]))
|
||||||
|
|
||||||
|
it("sorts descending", () =>
|
||||||
|
expectSearch({
|
||||||
|
query: {},
|
||||||
|
sort: "time",
|
||||||
|
sortOrder: SortOrder.DESCENDING,
|
||||||
|
}).toMatchExactly([
|
||||||
|
{ time: "15:30:00" },
|
||||||
|
{ time: "12:00:00" },
|
||||||
|
{ time: "10:45:00" },
|
||||||
|
{ time: "10:00:00" },
|
||||||
|
{ time: "00:00:00" },
|
||||||
|
]))
|
||||||
|
|
||||||
|
describe("sortType STRING", () => {
|
||||||
|
it("sorts ascending", () =>
|
||||||
|
expectSearch({
|
||||||
|
query: {},
|
||||||
|
sort: "time",
|
||||||
|
sortType: SortType.STRING,
|
||||||
|
sortOrder: SortOrder.ASCENDING,
|
||||||
|
}).toMatchExactly([
|
||||||
|
{ time: "00:00:00" },
|
||||||
|
{ time: "10:00:00" },
|
||||||
|
{ time: "10:45:00" },
|
||||||
|
{ time: "12:00:00" },
|
||||||
|
{ time: "15:30:00" },
|
||||||
|
]))
|
||||||
|
|
||||||
|
it("sorts descending", () =>
|
||||||
|
expectSearch({
|
||||||
|
query: {},
|
||||||
|
sort: "time",
|
||||||
|
sortType: SortType.STRING,
|
||||||
|
sortOrder: SortOrder.DESCENDING,
|
||||||
|
}).toMatchExactly([
|
||||||
|
{ time: "15:30:00" },
|
||||||
|
{ time: "12:00:00" },
|
||||||
|
{ time: "10:45:00" },
|
||||||
|
{ time: "10:00:00" },
|
||||||
|
{ time: "00:00:00" },
|
||||||
|
]))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue