Merge pull request #13726 from Budibase/fix-search-tests
Remove most of the date mocking in search.spec.ts
This commit is contained in:
commit
efa0c8289f
1 changed files with 23 additions and 19 deletions
|
@ -19,12 +19,8 @@ import {
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import _ from "lodash"
|
import _ from "lodash"
|
||||||
import tk from "timekeeper"
|
import tk from "timekeeper"
|
||||||
import { mocks } from "@budibase/backend-core/tests"
|
|
||||||
import { encodeJSBinding } from "@budibase/string-templates"
|
import { encodeJSBinding } from "@budibase/string-templates"
|
||||||
|
|
||||||
const serverTime = mocks.date.MOCK_DATE
|
|
||||||
tk.freeze(serverTime)
|
|
||||||
|
|
||||||
describe.each([
|
describe.each([
|
||||||
["lucene", undefined],
|
["lucene", undefined],
|
||||||
["sqs", undefined],
|
["sqs", undefined],
|
||||||
|
@ -252,8 +248,14 @@ describe.each([
|
||||||
describe("bindings", () => {
|
describe("bindings", () => {
|
||||||
let globalUsers: any = []
|
let globalUsers: any = []
|
||||||
|
|
||||||
const future = new Date(serverTime.getTime())
|
const serverTime = new Date()
|
||||||
future.setDate(future.getDate() + 30)
|
|
||||||
|
// In MariaDB and MySQL we only store dates to second precision, so we need
|
||||||
|
// to remove milliseconds from the server time to ensure searches work as
|
||||||
|
// expected.
|
||||||
|
serverTime.setMilliseconds(0)
|
||||||
|
|
||||||
|
const future = new Date(serverTime.getTime() + 1000 * 60 * 60 * 24 * 30)
|
||||||
|
|
||||||
const rows = (currentUser: User) => {
|
const rows = (currentUser: User) => {
|
||||||
return [
|
return [
|
||||||
|
@ -359,6 +361,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: {
|
||||||
|
@ -374,6 +377,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({
|
||||||
|
|
Loading…
Reference in a new issue