initial
Some checks failed
CI / test (push) Has been cancelled

This commit is contained in:
2026-06-26 09:21:14 +01:00
commit 194330fb47
40 changed files with 11873 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
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);
});
});