The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { resolveLocaleSelection, SYSTEM_LANGUAGE } from "@t3tools/client-runtime/locales"; |
| 2 | import { describe, expect, it } from "vite-plus/test"; |
| 3 | |
| 4 | import { DEFAULT_LOCALE, SUPPORTED_LOCALES } from "../../i18n/locales"; |
| 5 | import { |
| 6 | applySnoozePickerDate, |
| 7 | snoozeDateToPickerDate, |
| 8 | snoozePickerLabels, |
| 9 | } from "./customSnoozeDate"; |
| 10 | |
| 11 | describe("custom snooze calendar conversion", () => { |
| 12 | it("passes the local calendar day to Compose without shifting it across time zones", () => { |
| 13 | const date = new Date(2026, 8, 17, 0, 30); |
| 14 | expect(snoozeDateToPickerDate(date)).toBe("2026-09-17T00:00:00.000Z"); |
| 15 | }); |
| 16 | |
| 17 | it("applies Compose's UTC calendar day while retaining the local time", () => { |
| 18 | const date = new Date(2026, 8, 16, 23, 45); |
| 19 | const next = applySnoozePickerDate(date, new Date("2026-09-20T00:00:00Z")); |
| 20 | expect([ |
| 21 | next.getFullYear(), |
| 22 | next.getMonth(), |
| 23 | next.getDate(), |
| 24 | next.getHours(), |
| 25 | next.getMinutes(), |
| 26 | ]).toEqual([2026, 8, 20, 23, 45]); |
| 27 | expect(date.getDate()).toBe(16); |
| 28 | }); |
| 29 | |
| 30 | it.each([ |
| 31 | { language: SYSTEM_LANGUAGE, catalog: "en", dateLabel: "5 May" }, |
| 32 | { language: "fr", catalog: "fr", dateLabel: "5 mai" }, |
| 33 | ])("labels the picked date and time for the $language preference", (test) => { |
| 34 | const date = new Date(2027, 4, 5, 14, 30); |
| 35 | const { catalogLocale, formattingLocale } = resolveLocaleSelection( |
| 36 | test.language, |
| 37 | ["it-IT", "en-GB"], |
| 38 | SUPPORTED_LOCALES, |
| 39 | DEFAULT_LOCALE, |
| 40 | ); |
| 41 | expect(catalogLocale).toBe(test.catalog); |
| 42 | expect(snoozePickerLabels(date, formattingLocale, true)).toEqual({ |
| 43 | date: test.dateLabel, |
| 44 | time: "14:30", |
| 45 | }); |
| 46 | }); |
| 47 | }); |