import { describe, it, expect } from "vitest"; import { getLogicalToday, getLogicalYesterday, isWithinGraceWindow, } from "./day-boundary"; describe("day-boundary", () => { it("returns calendar date when boundary is midnight and after noon", () => { const now = new Date(2026, 5, 26, 14, 0, 0); expect(getLogicalToday(0, now)).toBe("2026-06-26"); }); it("returns previous calendar date when before boundary hour", () => { const now = new Date(2026, 5, 26, 1, 30, 0); expect(getLogicalToday(2, now)).toBe("2026-06-25"); }); it("returns current date when at or after boundary hour", () => { const now = new Date(2026, 5, 26, 2, 30, 0); expect(getLogicalToday(2, now)).toBe("2026-06-26"); }); it("computes logical yesterday", () => { const now = new Date(2026, 5, 26, 14, 0, 0); expect(getLogicalYesterday(0, now)).toBe("2026-06-25"); }); it("detects grace window after midnight", () => { const now = new Date(2026, 5, 26, 1, 0, 0); expect(isWithinGraceWindow(0, 4, now)).toBe(true); }); it("is outside grace window mid-day", () => { const now = new Date(2026, 5, 26, 14, 0, 0); expect(isWithinGraceWindow(0, 4, now)).toBe(false); }); });