From 49c494f3ca943a384ef463fbf80448c34b816e2c Mon Sep 17 00:00:00 2001 From: Harley Harris Date: Wed, 13 Dec 2023 11:52:00 +0000 Subject: [PATCH] update date mock to use UTC (+0) code to align with gitaction timezone environment and set the system time using this mock --- test/mock/text.mock.ts | 2 +- test/unit/formatting/humanFormat.spec.ts | 4 ++-- test/unit/formatting/jsonFormat.spec.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/mock/text.mock.ts b/test/mock/text.mock.ts index 960084f..8bca3dc 100644 --- a/test/mock/text.mock.ts +++ b/test/mock/text.mock.ts @@ -1,2 +1,2 @@ export const MOCK_NAMESPACE = 'namespace'; -export const MOCK_DATE = '1970-01-01 01:00:00.000+1'; +export const MOCK_DATE = '1999-01-01 00:00:00.000+0'; diff --git a/test/unit/formatting/humanFormat.spec.ts b/test/unit/formatting/humanFormat.spec.ts index b01b90f..2de1dfe 100644 --- a/test/unit/formatting/humanFormat.spec.ts +++ b/test/unit/formatting/humanFormat.spec.ts @@ -3,7 +3,7 @@ import winston from 'winston'; import * as humanFormat from '../../../src/formatting/humanFormat'; import { MOCK_INFO, MOCK_HUMAN_MESSAGE, MOCK_FORMATTED_HUMAN_MESSAGE } from '../../mock/data.mock'; -import { MOCK_NAMESPACE } from '../../mock/text.mock'; +import { MOCK_DATE, MOCK_NAMESPACE } from '../../mock/text.mock'; describe('humanFormat test suites', () => { afterEach(() => { @@ -12,7 +12,7 @@ describe('humanFormat test suites', () => { describe('setHumanMessage test', () => { beforeEach(() => { - jest.useFakeTimers().setSystemTime(); + jest.useFakeTimers().setSystemTime(new Date(MOCK_DATE)); }); afterEach(() => { diff --git a/test/unit/formatting/jsonFormat.spec.ts b/test/unit/formatting/jsonFormat.spec.ts index 1392255..88f0cf5 100644 --- a/test/unit/formatting/jsonFormat.spec.ts +++ b/test/unit/formatting/jsonFormat.spec.ts @@ -4,7 +4,7 @@ import winston from 'winston'; import * as jsonFormat from '../../../src/formatting/jsonFormat'; import { MOCK_INFO, MOCK_JSON_OBJECT, MOCK_JSON_STRINGIFIED } from '../../mock/data.mock'; -import { MOCK_NAMESPACE } from '../../mock/text.mock'; +import { MOCK_DATE, MOCK_NAMESPACE } from '../../mock/text.mock'; describe('jsonFormat test suites', () => { afterEach(() => { @@ -13,7 +13,7 @@ describe('jsonFormat test suites', () => { describe('setJsonMessage Test', () => { beforeEach(() => { - jest.useFakeTimers().setSystemTime(); + jest.useFakeTimers().setSystemTime(new Date(MOCK_DATE)); }); afterEach(() => { jest.useRealTimers();