import "@testing-library/jest-dom/vitest";
import { describe, expect, it } from "vitest";
import { render, screen } from "@testing-library/react";
import PatternGlyph, {
PATTERN_GLYPH_OPTIONS,
} from "../../app/components/asset/PatternGlyph";
describe("PatternGlyph", () => {
it("renders every glyph at 48 and 24", () => {
const { rerender } = render(
,
);
expect(document.querySelector("svg")).toHaveAttribute("width", "48");
expect(document.querySelector("svg")).toHaveAttribute("aria-hidden");
rerender();
expect(document.querySelector("svg")).toHaveAttribute("width", "24");
for (const glyph of PATTERN_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: "Conflict council. Named members hear what the first steps could not settle.",
}),
).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)]",
);
});
});