From 161c5305113db80edf9b3bf9f846163749f0c6f0 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Tue, 12 Apr 2022 15:57:59 -0700 Subject: [PATCH] Fix tests per https://github.com/kulshekhar/ts-jest/issues/1057#issuecomment-1068342692 --- src/coalesce-vue/package.json | 9 ++++++++- src/coalesce-vue/src/model.ts | 2 +- src/coalesce-vue/test/api-client.spec.ts | 2 ++ src/coalesce-vue/test/model.display.spec.ts | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/coalesce-vue/package.json b/src/coalesce-vue/package.json index 5fca2a57c..65917b226 100644 --- a/src/coalesce-vue/package.json +++ b/src/coalesce-vue/package.json @@ -69,6 +69,12 @@ "transform": { "^.+\\.(j|t)sx?$": "ts-jest" }, + "globals": { + "ts-jest": { + "useESM": true + } + }, + "extensionsToTreatAsEsm": [".ts"], "collectCoverageFrom": [ "src/**", "!src/index.ts" @@ -77,7 +83,8 @@ "^vue$": "vue/dist/vue.common.js", "//": "Map the esm version of libs to the non-esm for the tests - jest doesn't do well with es modules & typescript. By some sheer chance of luck, the import statements can be written the same between the es and non-es versions of the files.", "^date-fns/esm$": "date-fns", - "lodash-es(.*)": "lodash$1" + "lodash-es(.*)": "lodash$1", + "(.+)\\.js": "$1" }, "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", "moduleFileExtensions": [ diff --git a/src/coalesce-vue/src/model.ts b/src/coalesce-vue/src/model.ts index 8194b4287..b8e3110ec 100644 --- a/src/coalesce-vue/src/model.ts +++ b/src/coalesce-vue/src/model.ts @@ -765,7 +765,7 @@ class DisplayVisitor extends Visitor< formatString = "M/d/yyyy"; break; default: - formatString = "M/d/yyyy h:mm:ss aaa"; + formatString = "M/d/yyyy h:mm:ss aa"; break; } } diff --git a/src/coalesce-vue/test/api-client.spec.ts b/src/coalesce-vue/test/api-client.spec.ts index 14e315dff..39218470f 100644 --- a/src/coalesce-vue/test/api-client.spec.ts +++ b/src/coalesce-vue/test/api-client.spec.ts @@ -524,6 +524,8 @@ describe("$makeCaller", () => { AxiosClient.defaults.adapter = jest.fn().mockImplementation(async () => >{ data: blob, status: 200, + statusText: "OK", + config: {}, headers: {'content-disposition': "attachment; filename=\"sample-mp4-file small.mp4\"; filename*=UTF-8''sample-mp4-file%20small.mp4"} }) diff --git a/src/coalesce-vue/test/model.display.spec.ts b/src/coalesce-vue/test/model.display.spec.ts index 6e7a86b47..19aab21f0 100644 --- a/src/coalesce-vue/test/model.display.spec.ts +++ b/src/coalesce-vue/test/model.display.spec.ts @@ -102,7 +102,7 @@ describe.each([ { meta: studentProps.birthDate, model: "1990-01-02T03:04:05.000-08:00", // We define the expected using date-fns's format to make this test timezone-independent. - display: format(new Date("1990-01-02T03:04:05.000-08:00"), "M/d/yyyy h:mm:ss aaa") }, + display: format(new Date("1990-01-02T03:04:05.000-08:00"), "M/d/yyyy h:mm:ss aa") }, ...undisplayable(studentProps.birthDate, true, 123, "abc", {}, [], new Date("!!Invalid") ), { meta: studentProps.grade, model: undefined, display: null },