Fix date math problem in search tests.

This commit is contained in:
Sam Rose 2024-05-20 12:23:03 +01:00
parent 39f59c076a
commit 079318379d
No known key found for this signature in database
1 changed files with 17 additions and 16 deletions

View File

@ -21,9 +21,6 @@ import _ from "lodash"
import tk from "timekeeper" import tk from "timekeeper"
import { encodeJSBinding } from "@budibase/string-templates" import { encodeJSBinding } from "@budibase/string-templates"
const serverTime = new Date("2024-05-06T00:00:00.000Z")
tk.freeze(serverTime)
describe.each([ describe.each([
["lucene", undefined], ["lucene", undefined],
["sqs", undefined], ["sqs", undefined],
@ -251,6 +248,8 @@ describe.each([
describe("bindings", () => { describe("bindings", () => {
let globalUsers: any = [] let globalUsers: any = []
const serverTime = new Date()
serverTime.setMilliseconds(0)
const future = new Date(serverTime.getTime()) const future = new Date(serverTime.getTime())
future.setDate(future.getDate() + 30) future.setDate(future.getDate() + 30)
@ -358,6 +357,7 @@ describe.each([
}) })
it("should parse the date binding and return all rows after the resolved value", async () => { it("should parse the date binding and return all rows after the resolved value", async () => {
await tk.withFreeze(serverTime, async () => {
await expectQuery({ await expectQuery({
range: { range: {
appointment: { appointment: {
@ -373,6 +373,7 @@ describe.each([
{ name: "serverDate", appointment: serverTime.toISOString() }, { name: "serverDate", appointment: serverTime.toISOString() },
]) ])
}) })
})
it("should parse the date binding and return all rows before the resolved value", async () => { it("should parse the date binding and return all rows before the resolved value", async () => {
await expectQuery({ await expectQuery({