The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | // @effect-diagnostics globalDate:off -- Tests exercise local calendar and elapsed-time snooze input. |
| 2 | import { afterEach, describe, expect, it, vi } from "vite-plus/test"; |
| 3 | import { resolveCustomSnooze } from "./threadSettled.ts"; |
| 4 | |
| 5 | const now = new Date(2026, 8, 14, 14, 30); |
| 6 | |
| 7 | afterEach(() => vi.unstubAllEnvs()); |
| 8 | |
| 9 | describe("custom snooze", () => { |
| 10 | it.each([ |
| 11 | ["2026-09-14", "14:30"], |
| 12 | ["2027-02-29", "09:00"], |
| 13 | ["2026-09-15", "24:00"], |
| 14 | ])("rejects invalid or non-future calendar input %s %s", (date, time) => { |
| 15 | expect(resolveCustomSnooze({ mode: "date", date, time }, now)).toBeNull(); |
| 16 | }); |
| 17 | |
| 18 | it.each([ |
| 19 | ["minutes", "45", 45 * 60_000], |
| 20 | ["hours", "1.5", 90 * 60_000], |
| 21 | ["days", "2", 48 * 3_600_000], |
| 22 | ] as const)("resolves %s from the confirmation time", (unit, amount, elapsed) => { |
| 23 | const confirmedAt = new Date(now.getTime() + 5 * 60_000); |
| 24 | expect(resolveCustomSnooze({ mode: "duration", amount, unit }, confirmedAt)).toBe( |
| 25 | new Date(confirmedAt.getTime() + elapsed).toISOString(), |
| 26 | ); |
| 27 | }); |
| 28 | |
| 29 | it.each(["0", "NaN", "1e300"])("rejects invalid duration %s", (amount) => { |
| 30 | expect(resolveCustomSnooze({ mode: "duration", amount, unit: "hours" }, now)).toBeNull(); |
| 31 | }); |
| 32 | |
| 33 | it("rejects nonexistent local times at the spring DST transition", () => { |
| 34 | vi.stubEnv("TZ", "America/Los_Angeles"); |
| 35 | expect( |
| 36 | resolveCustomSnooze( |
| 37 | { mode: "date", date: "2027-03-14", time: "02:30" }, |
| 38 | new Date("2027-03-01T00:00:00Z"), |
| 39 | ), |
| 40 | ).toBeNull(); |
| 41 | }); |
| 42 | |
| 43 | it("treats duration days as 24 hours across DST", () => { |
| 44 | vi.stubEnv("TZ", "America/Los_Angeles"); |
| 45 | const before = new Date(2027, 2, 13, 12); |
| 46 | const wake = resolveCustomSnooze({ mode: "duration", amount: "1", unit: "days" }, before); |
| 47 | expect(wake).toBe(new Date(2027, 2, 14, 13).toISOString()); |
| 48 | }); |
| 49 | }); |