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).
35 lines
1.4 KiB
TypeScript
35 lines
1.4 KiB
TypeScript
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-р сар");
|
||
});
|
||
});
|