From 8c1e539fc7073dd81bf463f5b6a17fb9345dae76 Mon Sep 17 00:00:00 2001 From: Adria Navarro Redo Date: Thu, 26 Jan 2023 11:55:11 +0000 Subject: [PATCH] Fix date related tests --- packages/server/src/api/routes/tests/query.spec.js | 3 +++ packages/server/src/api/routes/tests/row.spec.js | 9 +++++++-- packages/server/src/migrations/tests/index.spec.ts | 4 ---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/server/src/api/routes/tests/query.spec.js b/packages/server/src/api/routes/tests/query.spec.js index f9f2fa8347..f0cfdaa76f 100644 --- a/packages/server/src/api/routes/tests/query.spec.js +++ b/packages/server/src/api/routes/tests/query.spec.js @@ -1,3 +1,6 @@ +const tk = require( "timekeeper") +tk.freeze(Date.now()) + // Mock out postgres for this jest.mock("pg") jest.mock("node-fetch") diff --git a/packages/server/src/api/routes/tests/row.spec.js b/packages/server/src/api/routes/tests/row.spec.js index cd09302dcc..740c833eb8 100644 --- a/packages/server/src/api/routes/tests/row.spec.js +++ b/packages/server/src/api/routes/tests/row.spec.js @@ -1,3 +1,8 @@ +const tk = require( "timekeeper") +const timestamp = new Date("2023-01-26T11:48:57.597Z").toISOString() +tk.freeze(timestamp) + + const { outputProcessing } = require("../../../utilities/rowProcessor") const setup = require("./utilities") const { basicRow } = setup.structures @@ -111,8 +116,8 @@ describe("/rows", () => { _id: existing._id, _rev: existing._rev, type: "row", - createdAt: "2020-01-01T00:00:00.000Z", - updatedAt: "2020-01-01T00:00:00.000Z", + createdAt: timestamp, + updatedAt: timestamp, }) await assertQueryUsage(queryUsage + 1) }) diff --git a/packages/server/src/migrations/tests/index.spec.ts b/packages/server/src/migrations/tests/index.spec.ts index 4540d8f61f..8e52831c5e 100644 --- a/packages/server/src/migrations/tests/index.spec.ts +++ b/packages/server/src/migrations/tests/index.spec.ts @@ -25,10 +25,6 @@ const clearMigrations = async () => { jest.setTimeout(10000) -afterAll(() => { - tk.reset() -}) - describe("migrations", () => { const config = new TestConfig()