From d9b725e9ba1c259dd214e8f1510f95cb5182bdaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Connor=20B=C3=A4r?= Date: Wed, 14 Aug 2024 15:30:52 +0200 Subject: [PATCH] Fix unit tests --- src/lib/date-time-format/tests/format-to-parts.spec.ts | 1 + src/lib/date-time-format/tests/format.spec.ts | 1 + src/lib/date-time-format/tests/resolve-format.spec.ts | 1 + src/lib/date-time-format/tests/unsupported-styles.spec.ts | 1 + vitest.setup.js | 3 ++- 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/date-time-format/tests/format-to-parts.spec.ts b/src/lib/date-time-format/tests/format-to-parts.spec.ts index 000a306..ed20769 100644 --- a/src/lib/date-time-format/tests/format-to-parts.spec.ts +++ b/src/lib/date-time-format/tests/format-to-parts.spec.ts @@ -14,6 +14,7 @@ */ import { describe, it, expect } from 'vitest'; +import { Intl } from 'temporal-polyfill'; import { formatDateTimeToParts } from '..'; diff --git a/src/lib/date-time-format/tests/format.spec.ts b/src/lib/date-time-format/tests/format.spec.ts index b1fcc6e..6627be7 100644 --- a/src/lib/date-time-format/tests/format.spec.ts +++ b/src/lib/date-time-format/tests/format.spec.ts @@ -14,6 +14,7 @@ */ import { describe, it, expect } from 'vitest'; +import { Intl } from 'temporal-polyfill'; import { formatDateTime, formatDate, formatTime } from '..'; diff --git a/src/lib/date-time-format/tests/resolve-format.spec.ts b/src/lib/date-time-format/tests/resolve-format.spec.ts index b74a712..458e2d1 100644 --- a/src/lib/date-time-format/tests/resolve-format.spec.ts +++ b/src/lib/date-time-format/tests/resolve-format.spec.ts @@ -14,6 +14,7 @@ */ import { describe, it, expect } from 'vitest'; +import { Intl } from 'temporal-polyfill'; import { resolveDateTimeFormat } from '..'; diff --git a/src/lib/date-time-format/tests/unsupported-styles.spec.ts b/src/lib/date-time-format/tests/unsupported-styles.spec.ts index 8df94e8..f1d122e 100644 --- a/src/lib/date-time-format/tests/unsupported-styles.spec.ts +++ b/src/lib/date-time-format/tests/unsupported-styles.spec.ts @@ -14,6 +14,7 @@ */ import { vi, describe, it, expect } from 'vitest'; +import { Intl } from 'temporal-polyfill'; import { formatDateTime } from '..'; diff --git a/vitest.setup.js b/vitest.setup.js index 16380bc..a3f5586 100644 --- a/vitest.setup.js +++ b/vitest.setup.js @@ -1,10 +1,11 @@ import { vi, expect } from 'vitest'; import * as matchers from 'jest-extended'; +import { Intl as IntlWithTemporal } from 'temporal-polyfill'; expect.extend(matchers); vi.spyOn(Intl, 'NumberFormat'); -vi.spyOn(Intl, 'DateTimeFormat'); +vi.spyOn(IntlWithTemporal, 'DateTimeFormat'); // Apparently, Node.js doesn't implement these APIs. // The mocked return value is based on the test value `1001001001.11111`