mercury-web/src/features/accounting/monthRange.test.ts
Munkherdene e478ca5826 feat(web): transactions month nav + category filters + categorize-review queue
Adds a month navigator and category filter chips to the Тооцоо list, plus a
categorize-review flow at /accounting/review for bulk-assigning categories to
uncategorized merchants (grouped by matchKey, biggest spend first).
2026-08-22 23:00:09 +08:00

35 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { describe, expect, it } from "vitest";
import { monthLabel, monthRange } from "./monthRange";
describe("monthRange", () => {
it("returns the first and last day of the base month at offset 0", () => {
expect(monthRange(0, new Date(2026, 7, 15))).toEqual({ from: "2026-08-01", to: "2026-08-31" });
});
it("steps back a month, crossing a year boundary", () => {
expect(monthRange(-1, new Date(2026, 0, 10))).toEqual({ from: "2025-12-01", to: "2025-12-31" });
});
it("steps forward a month, crossing a year boundary", () => {
expect(monthRange(1, new Date(2025, 11, 20))).toEqual({ from: "2026-01-01", to: "2026-01-31" });
});
it("handles a short month (February, non-leap year)", () => {
expect(monthRange(0, new Date(2026, 1, 1))).toEqual({ from: "2026-02-01", to: "2026-02-28" });
});
it("handles a leap-year February", () => {
expect(monthRange(0, new Date(2028, 1, 1))).toEqual({ from: "2028-02-01", to: "2028-02-29" });
});
});
describe("monthLabel", () => {
it("formats as '<year> оны <month>-р сар'", () => {
expect(monthLabel(0, new Date(2026, 7, 15))).toBe("2026 оны 8-р сар");
});
it("rolls the year when stepping across January", () => {
expect(monthLabel(-1, new Date(2026, 0, 5))).toBe("2025 оны 12-р сар");
expect(monthLabel(1, new Date(2025, 11, 5))).toBe("2026 оны 1-р сар");
});
});