profileShare

rasmusjy / tasteprint

Read-only snapshot

No repository description.

main default branch 169 files Expires Sep 13, 2026, 9:06 AM
format.test.ts 831 bytes
1 import { describe, expect, it, vi } from "vitest";
2 import { formatDate, formatDateRange, initials, todayInput } from "./format";
3
4 describe("format helpers", () => {
5 it("formats dates and ranges without timezone drift", () => {
6 expect(formatDate("2026-08-09")).toContain("9 Aug 2026");
7 expect(formatDateRange("2026-08-09", "2026-08-09")).toContain("9 Aug 2026");
8 expect(formatDateRange("2026-08-09", "2026-08-12")).toBe("9 Aug to 12 Aug");
9 });
10
11 it("builds two-letter initials", () => {
12 expect(initials("Rasmus Jürimäe")).toBe("RJ");
13 expect(initials("Maria")).toBe("M");
14 });
15
16 it("returns the local calendar day for date inputs", () => {
17 vi.useFakeTimers();
18 vi.setSystemTime(new Date("2026-08-09T22:30:00+03:00"));
19 expect(todayInput()).toBe("2026-08-09");
20 vi.useRealTimers();
21 });
22 });
23