From 18d36ab51e950fd6b63ca9b5e627051f0e99aa37 Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Thu, 3 Feb 2022 13:10:35 +0100 Subject: [PATCH] Use jest fake time --- .../tests/unit/views/spaces/Project.spec.js | 9 ++++++++- .../unit/views/spaces/__snapshots__/Project.spec.js.snap | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/web-app-files/tests/unit/views/spaces/Project.spec.js b/packages/web-app-files/tests/unit/views/spaces/Project.spec.js index 5eb668d6147..a028b6b5d9c 100644 --- a/packages/web-app-files/tests/unit/views/spaces/Project.spec.js +++ b/packages/web-app-files/tests/unit/views/spaces/Project.spec.js @@ -13,7 +13,6 @@ localVue.use(GetTextPlugin, { silent: true }) -beforeEach(mockAxios.reset) const composables = '@files/src/composables/index' jest.mock(composables, () => ({ @@ -27,8 +26,16 @@ jest.mock(composables, () => ({ }) })) +beforeEach(mockAxios.reset) + +beforeEach(() => { + jest.useFakeTimers('modern') + jest.setSystemTime(new Date(2020, 3, 1)) +}) + afterEach(() => { jest.unmock(composables) + jest.useRealTimers() }) window.ResizeObserver = diff --git a/packages/web-app-files/tests/unit/views/spaces/__snapshots__/Project.spec.js.snap b/packages/web-app-files/tests/unit/views/spaces/__snapshots__/Project.spec.js.snap index 5c9517a1f9d..0b590d817a3 100644 --- a/packages/web-app-files/tests/unit/views/spaces/__snapshots__/Project.spec.js.snap +++ b/packages/web-app-files/tests/unit/views/spaces/__snapshots__/Project.spec.js.snap @@ -48,7 +48,7 @@ exports[`Spaces project component resources should show resources if given 1`] = 7.5 MB - 7 months ago + in 1 year