Files
HealthLog/src/lib/__tests__/time-window-format.test.ts
T
Marc-André BombeckandClaude Opus 4.7 ae2f671321 style: prettier on touched test + e2e files
Run prettier on the test, e2e, and component files this v1.4.19
A8 wave touched. The .planning/* and docs/audit/* prettier
warnings are pre-existing baseline noise — left alone to keep
this commit narrow.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-10 13:58:30 +02:00

41 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, test } from "vitest";
import {
formatTimeWindowPart,
formatTimeWindowRange,
} from "@/lib/time-window-format";
describe("formatTimeWindowPart", () => {
test("zero-pads single-digit hours", () => {
expect(formatTimeWindowPart("8:00")).toBe("08:00");
});
test("preserves two-digit hours", () => {
expect(formatTimeWindowPart("19:30")).toBe("19:30");
});
test("returns input unchanged when not a HH:MM string", () => {
expect(formatTimeWindowPart("invalid")).toBe("invalid");
});
});
describe("formatTimeWindowRange", () => {
test("German locale renders 'bis ... Uhr' (default behaviour preserved)", () => {
expect(formatTimeWindowRange("19:00", "23:00", "de")).toBe(
"19:00 bis 23:00 Uhr",
);
});
test("English locale renders 'from ... to ...' instead of mixed-language 'bis Uhr'", () => {
// Regression for v1.4.19 F-01: app rendered "Today, 19:00 bis 23:00 Uhr"
// for English users because the formatter hard-coded German.
expect(formatTimeWindowRange("19:00", "23:00", "en")).toBe("19:00 – 23:00");
});
test("falls back to the German format when no locale is supplied", () => {
// Backwards-compat: existing call sites that have not been migrated
// continue to render the historic German string.
expect(formatTimeWindowRange("08:00", "12:00")).toBe("08:00 bis 12:00 Uhr");
});
});