import "@testing-library/jest-dom/vitest";
import { describe, expect, it } from "vitest";
import { render, screen } from "@testing-library/react";
import DiagramGlyph, {
DIAGRAM_GLYPH_OPTIONS,
} from "../../app/components/asset/DiagramGlyph";
describe("DiagramGlyph", () => {
it("renders every glyph at 48 and 24", () => {
const { rerender } = render(
,
);
expect(document.querySelector("svg")).toHaveAttribute("width", "48");
expect(document.querySelector("svg")).toHaveAttribute("height", "48");
expect(document.querySelector("svg")).toHaveAttribute("aria-hidden");
rerender();
expect(document.querySelector("svg")).toHaveAttribute("width", "24");
expect(document.querySelector("svg")).toHaveAttribute("height", "24");
for (const glyph of DIAGRAM_GLYPH_OPTIONS) {
rerender();
expect(document.querySelector("svg")).toBeInTheDocument();
}
});
it("names a diagram glyph and keeps a decorative glyph unlabeled", () => {
const { rerender } = render(
,
);
expect(
screen.getByRole("img", {
name: "Rotation. Roles move on a set schedule.",
}),
).toBeInTheDocument();
rerender();
expect(screen.queryByRole("img")).not.toBeInTheDocument();
expect(document.querySelector("svg")).toHaveAttribute("aria-hidden");
});
it("recolors with one text class", () => {
render(
,
);
expect(document.querySelector("svg")).toHaveClass(
"text-[var(--color-content-default-brand-primary)]",
);
});
});