From c94fb7eb5cd53651083885a525ad341ba30c16f3 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 11 Dec 2024 18:08:38 +0000 Subject: [PATCH 1/2] Change to en-US locale for date tests As per comment. Fixes the tests. --- test/unit-tests/utils/DateUtils-test.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/unit-tests/utils/DateUtils-test.ts b/test/unit-tests/utils/DateUtils-test.ts index 6112c19e4a2..d59b7d4235b 100644 --- a/test/unit-tests/utils/DateUtils-test.ts +++ b/test/unit-tests/utils/DateUtils-test.ts @@ -178,22 +178,26 @@ describe("formatDate", () => { it("should return time string if date is within same day", () => { const date = new Date(REPEATABLE_DATE.getTime() + 2 * HOUR_MS + 12 * MINUTE_MS); - expect(formatDate(date, false, "en-GB")).toMatchInlineSnapshot(`"19:10"`); + // We use en-US for these tests because there was a change in Node 22.12 which removed + // the comma after the weekday for en-GB which makes the test output different things + // on different node versions. I'm not sure what a better fix would be, so let's just use + // a local that happens to have a more stable formatting right now. + expect(formatDate(date, false, "en-US")).toMatchInlineSnapshot(`"19:10"`); }); it("should return time string with weekday if date is within last 6 days", () => { const date = new Date(REPEATABLE_DATE.getTime() - 6 * DAY_MS + 2 * HOUR_MS + 12 * MINUTE_MS); - expect(formatDate(date, false, "en-GB")).toMatchInlineSnapshot(`"Fri 19:10"`); + expect(formatDate(date, false, "en-US")).toMatchInlineSnapshot(`"Fri 19:10"`); }); it("should return time & date string without year if it is within the same year", () => { const date = new Date(REPEATABLE_DATE.getTime() - 66 * DAY_MS + 2 * HOUR_MS + 12 * MINUTE_MS); - expect(formatDate(date, false, "en-GB")).toMatchInlineSnapshot(`"Mon, 12 Sept, 19:10"`); + expect(formatDate(date, false, "en-US")).toMatchInlineSnapshot(`"Mon, Sep 12, 19:10"`); }); it("should return full time & date string otherwise", () => { const date = new Date(REPEATABLE_DATE.getTime() - 666 * DAY_MS + 2 * HOUR_MS + 12 * MINUTE_MS); - expect(formatDate(date, false, "en-GB")).toMatchInlineSnapshot(`"Wed, 20 Jan 2021, 19:10"`); + expect(formatDate(date, false, "en-US")).toMatchInlineSnapshot(`"Wed, Jan 20, 2021, 19:10"`); }); }); From b0ba1ee1d1021dfd49d0a8c4873da6abf208ef30 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 11 Dec 2024 18:27:28 +0000 Subject: [PATCH 2/2] Spell locale right Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> --- test/unit-tests/utils/DateUtils-test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit-tests/utils/DateUtils-test.ts b/test/unit-tests/utils/DateUtils-test.ts index d59b7d4235b..2007c8a05a3 100644 --- a/test/unit-tests/utils/DateUtils-test.ts +++ b/test/unit-tests/utils/DateUtils-test.ts @@ -181,7 +181,7 @@ describe("formatDate", () => { // We use en-US for these tests because there was a change in Node 22.12 which removed // the comma after the weekday for en-GB which makes the test output different things // on different node versions. I'm not sure what a better fix would be, so let's just use - // a local that happens to have a more stable formatting right now. + // a locale that happens to have a more stable formatting right now. expect(formatDate(date, false, "en-US")).toMatchInlineSnapshot(`"19:10"`); });