import { describe, it, expect } from "vitest"; import { resolveHighlightsReference } from "./useHighlights"; describe("resolveHighlightsReference", () => { const TODAY = new Date(2026, 3, 14); // April 14, 2026 it("falls back to the previous month when no params are provided", () => { expect(resolveHighlightsReference(null, null, TODAY)).toEqual({ year: 2026, month: 3 }); }); it("accepts a valid (year, month) pair from the URL", () => { expect(resolveHighlightsReference("2025", "11", TODAY)).toEqual({ year: 2025, month: 11 }); }); it("rejects non-integer values and falls back to the default", () => { expect(resolveHighlightsReference("abc", "3", TODAY)).toEqual({ year: 2026, month: 3 }); expect(resolveHighlightsReference("2026", "foo", TODAY)).toEqual({ year: 2026, month: 3 }); }); it("rejects out-of-range months and falls back to the default", () => { expect(resolveHighlightsReference("2026", "0", TODAY)).toEqual({ year: 2026, month: 3 }); expect(resolveHighlightsReference("2026", "13", TODAY)).toEqual({ year: 2026, month: 3 }); }); it("rejects absurd years and falls back to the default", () => { expect(resolveHighlightsReference("999", "6", TODAY)).toEqual({ year: 2026, month: 3 }); }); it("wraps January back to December of the previous year for the default", () => { expect(resolveHighlightsReference(null, null, new Date(2026, 0, 10))).toEqual({ year: 2025, month: 12, }); }); });