- Extract shared defaultReferencePeriod helper (src/utils/referencePeriod.ts) - useHighlights now reads ?refY=YYYY&refM=MM, defaults to previous month - getHighlights signature: (referenceYear, referenceMonth, ytdYear, windowDays, ...) - YTD tile pinned to Jan 1 of current civil year, independent of reference month - CompareReferenceMonthPicker surfaced on /reports/highlights - Hub highlights panel inherits the same default via useHighlights - useCartes and useCompare now delegate their default-period helpers to the shared util
16 lines
627 B
TypeScript
16 lines
627 B
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { defaultReferencePeriod } from "./referencePeriod";
|
|
|
|
describe("defaultReferencePeriod", () => {
|
|
it("returns the month before the given date", () => {
|
|
expect(defaultReferencePeriod(new Date(2026, 3, 15))).toEqual({ year: 2026, month: 3 });
|
|
});
|
|
|
|
it("wraps January back to December of the previous year", () => {
|
|
expect(defaultReferencePeriod(new Date(2026, 0, 10))).toEqual({ year: 2025, month: 12 });
|
|
});
|
|
|
|
it("handles the last day of a month", () => {
|
|
expect(defaultReferencePeriod(new Date(2026, 5, 30))).toEqual({ year: 2026, month: 5 });
|
|
});
|
|
});
|