Skip to content

Commit a755e39

Browse files
dbkrrichvdh
andauthored
Change to en-US locale for date tests (#28723)
* Change to en-US locale for date tests As per comment. Fixes the tests. * Spell locale right Co-authored-by: Richard van der Hoff <[email protected]> --------- Co-authored-by: Richard van der Hoff <[email protected]>
1 parent 8dff758 commit a755e39

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

test/unit-tests/utils/DateUtils-test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,22 +178,26 @@ describe("formatDate", () => {
178178

179179
it("should return time string if date is within same day", () => {
180180
const date = new Date(REPEATABLE_DATE.getTime() + 2 * HOUR_MS + 12 * MINUTE_MS);
181-
expect(formatDate(date, false, "en-GB")).toMatchInlineSnapshot(`"19:10"`);
181+
// We use en-US for these tests because there was a change in Node 22.12 which removed
182+
// the comma after the weekday for en-GB which makes the test output different things
183+
// on different node versions. I'm not sure what a better fix would be, so let's just use
184+
// a locale that happens to have a more stable formatting right now.
185+
expect(formatDate(date, false, "en-US")).toMatchInlineSnapshot(`"19:10"`);
182186
});
183187

184188
it("should return time string with weekday if date is within last 6 days", () => {
185189
const date = new Date(REPEATABLE_DATE.getTime() - 6 * DAY_MS + 2 * HOUR_MS + 12 * MINUTE_MS);
186-
expect(formatDate(date, false, "en-GB")).toMatchInlineSnapshot(`"Fri 19:10"`);
190+
expect(formatDate(date, false, "en-US")).toMatchInlineSnapshot(`"Fri 19:10"`);
187191
});
188192

189193
it("should return time & date string without year if it is within the same year", () => {
190194
const date = new Date(REPEATABLE_DATE.getTime() - 66 * DAY_MS + 2 * HOUR_MS + 12 * MINUTE_MS);
191-
expect(formatDate(date, false, "en-GB")).toMatchInlineSnapshot(`"Mon, 12 Sept, 19:10"`);
195+
expect(formatDate(date, false, "en-US")).toMatchInlineSnapshot(`"Mon, Sep 12, 19:10"`);
192196
});
193197

194198
it("should return full time & date string otherwise", () => {
195199
const date = new Date(REPEATABLE_DATE.getTime() - 666 * DAY_MS + 2 * HOUR_MS + 12 * MINUTE_MS);
196-
expect(formatDate(date, false, "en-GB")).toMatchInlineSnapshot(`"Wed, 20 Jan 2021, 19:10"`);
200+
expect(formatDate(date, false, "en-US")).toMatchInlineSnapshot(`"Wed, Jan 20, 2021, 19:10"`);
197201
});
198202
});
199203

0 commit comments

Comments
 (0)