From 345577fc529879815f20a5436bf694e62ab14b8c Mon Sep 17 00:00:00 2001 From: Ken Date: Tue, 10 Sep 2024 00:41:30 +0800 Subject: [PATCH] test: mock date within test --- .../FeedbackPage/utils/FeedbackCsvGenerator.test.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/frontend/src/features/admin-form/responses/FeedbackPage/utils/FeedbackCsvGenerator.test.ts b/frontend/src/features/admin-form/responses/FeedbackPage/utils/FeedbackCsvGenerator.test.ts index 5662f765bf..5ef4abb676 100644 --- a/frontend/src/features/admin-form/responses/FeedbackPage/utils/FeedbackCsvGenerator.test.ts +++ b/frontend/src/features/admin-form/responses/FeedbackPage/utils/FeedbackCsvGenerator.test.ts @@ -1,4 +1,5 @@ import { stringify } from 'csv-string' +import mockdate from 'mockdate' import moment from 'moment-timezone' import { DateString, FormFeedbackDto, FormId } from '~shared/types' @@ -8,6 +9,14 @@ import { FeedbackCsvGenerator } from './FeedbackCsvGenerator' const UTF8_BYTE_ORDER_MARK = '\uFEFF' describe('FeedbackCsvGenerator', () => { + beforeEach(() => { + mockdate.set(moment().toDate()) + }) + + afterEach(() => { + mockdate.reset() + }) + afterAll(() => { jest.clearAllMocks() })