import { afterAll, expect, mock, test } from "bun:test";
import { renderToStaticMarkup } from "react-dom/server";
// Model the production chunk cycle: Notice evaluates before its icon imports
// finish initializing, then the live exports become available before render.
mock.module("lucide-react", () => ({
CircleAlertIcon: undefined,
CircleCheckIcon: undefined,
InfoIcon: undefined,
TriangleAlertIcon: undefined,
}));
const { Notice } = await import("./notice");
mock.module("lucide-react", () => ({
CircleAlertIcon: () => ,
CircleCheckIcon: () => ,
InfoIcon: () => ,
TriangleAlertIcon: () => ,
}));
afterAll(() => mock.restore());
test("all five tones resolve live icons after late module initialization", () => {
for (const tone of ["muted", "info", "success", "waiting", "failed"] as const) {
const html = renderToStaticMarkup(
Body
,
);
expect(html).toContain(`data-icon="${tone === "muted" ? "info" : tone}"`);
expect(html).toContain(`${tone} title`);
expect(html).toContain("Body");
}
});
test("default tone, explicit icon overrides and icon suppression remain unchanged", () => {
expect(renderToStaticMarkup(Default)).toContain('data-icon="info"');
expect(
renderToStaticMarkup(
Hidden
,
),
).not.toContain("