Files
HealthLog/src/components/cycle/__tests__/field-info.test.tsx
T
Marc-André Bombeck 1f4ba5939d style: apply prettier across the tree
One-shot prettier pass so the new format:check gate starts from a clean
baseline. Formatting only — no behaviour change. Generator-owned and
vendored artifacts stay untouched via .prettierignore.
2026-06-19 22:20:31 +02:00

40 lines
1.3 KiB
TypeScript

import { describe, it, expect } from "vitest";
import { renderToStaticMarkup } from "react-dom/server";
import { FieldInfo } from "../field-info";
import { I18nProvider } from "@/lib/i18n/context";
function render(node: React.ReactNode) {
return renderToStaticMarkup(
<I18nProvider initialLocale="en">{node}</I18nProvider>,
);
}
describe("<FieldInfo>", () => {
it("is a real focusable button carrying the accessible label", () => {
const html = render(
<FieldInfo
label="What is basal body temperature?"
detail="Your resting temperature."
/>,
);
// A real <button type="button"> — keyboard- and SR-reachable, not hover-only.
expect(html).toContain('type="button"');
expect(html).toContain('aria-label="What is basal body temperature?"');
// The e2e hook the cycle sheet asserts on.
expect(html).toContain('data-slot="cycle-field-info"');
});
it("starts closed so the explainer opens on tap/focus, not hover-only", () => {
// Radix renders the tooltip content lazily (portal, on open); the trigger
// therefore reports a closed state until interacted with.
const html = render(
<FieldInfo
label="Cervical mucus"
detail="Discharge changes across the cycle."
/>,
);
expect(html).toContain('data-state="closed"');
});
});