Files
beaver-calendar/tests/due.test.ts
T

29 lines
1.0 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
daysFromToday,
dueLabel,
dueTone,
nextFriday,
} from "../src/lib/due";
describe("due helpers read the day they are given", () => {
it("labels against the given today, not the wall clock", () => {
expect(dueLabel("2026-08-23", "2026-08-23")).toBe("today");
expect(dueLabel("2026-08-24", "2026-08-23")).toBe("tomorrow");
expect(dueLabel("2026-08-22", "2026-08-23")).toBe("yesterday");
expect(dueLabel("2026-08-23", "2026-08-30")).toBe("Aug 23");
});
it("tones against the given today", () => {
expect(dueTone("2026-08-22", "2026-08-23")).toBe("overdue");
expect(dueTone("2026-08-24", "2026-08-23")).toBe("soon");
expect(dueTone("2026-09-24", "2026-08-23")).toBe("normal");
expect(daysFromToday("2026-09-02", "2026-08-23")).toBe(10);
});
it("finds the friday after the given day, never the same one", () => {
expect(nextFriday("2026-08-23")).toBe("2026-08-28");
expect(nextFriday("2026-08-28")).toBe("2026-09-04");
});
});