master @ 35 LINES
[ HISTORY ] [ UP ]
┌─ TS ───────────────────────────────────────────────────────────────────────┐
│ import { describe, expect, it } from "vitest"; │
│ import { buildCalendar, CAL_W } from "./Calendar"; │
│ import { len } from "../../lib/ascii"; │
│ │
│ describe("buildCalendar", () => { │
│ it("lays out July 2026 starting on Wednesday", () => { │
│ const lines = buildCalendar(2026, 7).split("\n"); │
│ expect(lines[0].trim()).toBe("JULY 2026"); │
│ expect(lines[1]).toBe("MO TU WE TH FR SA SU"); │
│ expect(lines[2]).toBe(" 1 2 3 4 5"); │
│ expect(lines.at(-1)).toBe("27 28 29 30 31"); │
│ }); │
│ │
│ it("never exceeds the calendar width", () => { │
│ for (const m of [1, 2, 6, 12]) { │
│ for (const ln of buildCalendar(2026, m).split("\n")) { │
│ expect(len(ln)).toBeLessThanOrEqual(CAL_W); │
│ } │
│ } │
│ }); │
│ │
│ it("marks days with a * in the separator column", () => { │
│ const out = buildCalendar(2026, 7, [17]); │
│ expect(out).toContain("*17"); │
│ // grid alignment unchanged: the 16 stays in place │
│ const line = out.split("\n").find((l) => l.includes("17"))!; │
│ expect(line.indexOf("17")).toBe(line.indexOf("16") + 3); │
│ }); │
│ │
│ it("handles a February that starts on Monday", () => { │
│ const lines = buildCalendar(2027, 2).split("\n"); │
│ expect(lines[2]).toBe(" 1 2 3 4 5 6 7"); │
│ }); │
│ }); │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ TS ─────────────────────────────────┐
│ import { describe, expect, it } from "vitest │
│ "; │
│ import { buildCalendar, CAL_W } from "./Cale │
│ ndar"; │
│ import { len } from "../../lib/ascii"; │
│ │
│ describe("buildCalendar", () => { │
│ it("lays out July 2026 starting on Wednesd │
│ ay", () => { │
│ const lines = buildCalendar(2026, 7).spl │
│ it("\n"); │
│ expect(lines[0].trim()).toBe("JULY 2026" │
│ ); │
│ expect(lines[1]).toBe("MO TU WE TH FR SA │
│ SU"); │
│ expect(lines[2]).toBe(" 1 2 3 4 │
│ 5"); │
│ expect(lines.at(-1)).toBe("27 28 29 30 3 │
│ 1"); │
│ }); │
│ │
│ it("never exceeds the calendar width", () │
│ => { │
│ for (const m of [1, 2, 6, 12]) { │
│ for (const ln of buildCalendar(2026, m │
│ ).split("\n")) { │
│ expect(len(ln)).toBeLessThanOrEqual( │
│ CAL_W); │
│ } │
│ } │
│ }); │
│ │
│ it("marks days with a * in the separator c │
│ olumn", () => { │
│ const out = buildCalendar(2026, 7, [17]) │
│ ; │
│ expect(out).toContain("*17"); │
│ // grid alignment unchanged: the 16 stay │
│ s in place │
│ const line = out.split("\n").find((l) => │
│ l.includes("17"))!; │
│ expect(line.indexOf("17")).toBe(line.ind │
│ exOf("16") + 3); │
│ }); │
│ │
│ it("handles a February that starts on Mond │
│ ay", () => { │
│ const lines = buildCalendar(2027, 2).spl │
│ it("\n"); │
│ expect(lines[2]).toBe(" 1 2 3 4 5 6 │
│ 7"); │
│ }); │
│ }); │
└──────────────────────────────────────────────┘
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET