1import { describe, expect, it } from "vite-plus/test";
2
3import {
4 applySnoozePickerDate,
5 applySnoozePickerTime,
6 snoozeDateToPickerDate,
7} from "./customSnoozeDate";
8
9describe("custom snooze calendar conversion", () => {
10 it("passes the local calendar day to Compose without shifting it across time zones", () => {
11 const date = new Date(2026, 8, 17, 0, 30);
12 expect(snoozeDateToPickerDate(date)).toBe("2026-09-17T00:00:00.000Z");
13 });
14
15 it("applies Compose's UTC calendar day while retaining the local time", () => {
16 const date = new Date(2026, 8, 16, 23, 45);
17 const next = applySnoozePickerDate(date, new Date("2026-09-20T00:00:00Z"));
18 expect([
19 next.getFullYear(),
20 next.getMonth(),
21 next.getDate(),
22 next.getHours(),
23 next.getMinutes(),
24 ]).toEqual([2026, 8, 20, 23, 45]);
25 expect(date.getDate()).toBe(16);
26 });
27
28 it("applies a picked local time without changing the chosen calendar day", () => {
29 const date = new Date(2026, 8, 20, 23, 45);
30 const next = applySnoozePickerTime(date, new Date(2026, 8, 16, 8, 15, 30));
31 expect([next.getDate(), next.getHours(), next.getMinutes(), next.getSeconds()]).toEqual([
32 20, 8, 15, 0,
33 ]);
34 expect(date.getHours()).toBe(23);
35 });
36});