import { describe, it, expect } from "vitest"; import { renderToStaticMarkup } from "react-dom/server"; import { CycleRing } from "../cycle-ring"; import { I18nProvider } from "@/lib/i18n/context"; function render(node: React.ReactNode, locale: "en" | "de" = "en") { return renderToStaticMarkup( {node}, ); } describe("", () => { it("renders the root data-slot tagged with the active phase", () => { const html = render( , ); expect(html).toContain('data-slot="cycle-ring"'); expect(html).toContain('data-phase="FOLLICULAR"'); }); it("shows the day-of-cycle number as centred text", () => { const html = render( , ); expect(html).toContain(">12<"); }); it("carries a phase-aware aria-label (never colour-only)", () => { const html = render( , ); expect(html).toContain('role="img"'); expect(html).toContain("aria-label"); // The label restates the day + phase. expect(html).toContain("3"); }); it("parks the day-1 marker at the 12-o'clock origin (no double-rotate)", () => { // The carries `-rotate-90`, so day 1 (progress 0, angle 0) must // land at the un-rotated 3-o'clock SVG point (cx ≈ CX + R, cy ≈ CX) which // renders at the top. The prior `-π/2` bug parked it at cx ≈ CX (9 o'clock // after rotation). R = (100 - 8) / 2 = 46, CX = 50. const html = render( , ); // The marker circle's cx is the last with a stroke-width of 2. expect(html).toMatch(/cx="9[0-9](\.\d+)?"/); }); it("renders the no-cycle state for a null day with a fallback aria-label", () => { const html = render( , ); expect(html).toContain('data-phase="none"'); expect(html).toContain('role="img"'); }); });