From cde1d6f56aa88e443e6fc4affb8fbd2018421a95 Mon Sep 17 00:00:00 2001 From: Harley Harris Date: Wed, 13 Dec 2023 10:42:40 +0000 Subject: [PATCH 1/2] add build and test workflow --- .github/workflows/build-and-test.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/build-and-test.yml diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..3e3a015 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,21 @@ +name: Build and Test Checks + +on: [pull_request] + +jobs: + build-and-test: + + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: '20.x' + + - run: npm ci + - run: npm run build + - run: npm test \ No newline at end of file From 49c494f3ca943a384ef463fbf80448c34b816e2c Mon Sep 17 00:00:00 2001 From: Harley Harris Date: Wed, 13 Dec 2023 11:52:00 +0000 Subject: [PATCH 2/2] 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();