Frontend security / security (push) Successful in 9s
Frontend verify / verify (push) Successful in 5m27s
Frontend security / security (pull_request) Successful in 10s
Frontend verify / verify (pull_request) Successful in 5m24s
Conventional commits / commits (pull_request) Failing after 26s
OpenSpec change: evolve-frontend-stack
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { render, screen } from "@testing-library/react";
|
|
import { describe, expect, it } from "vitest";
|
|
import { AddIcon, DeleteIcon, EditIcon } from "./index";
|
|
|
|
describe("icon accessibility", () => {
|
|
it.each([AddIcon, EditIcon, DeleteIcon])(
|
|
"keeps decoration hidden and exposes explicitly named images: %s",
|
|
(Icon) => {
|
|
const { rerender } = render(
|
|
<button type="button" aria-label="Действие">
|
|
<Icon />
|
|
</button>,
|
|
);
|
|
expect(screen.queryByRole("img")).not.toBeInTheDocument();
|
|
expect(
|
|
screen.getByRole("button", { name: "Действие" }).querySelector("svg"),
|
|
).toHaveAttribute("focusable", "false");
|
|
rerender(
|
|
<Icon
|
|
aria-hidden={false}
|
|
role="img"
|
|
aria-label="Пример"
|
|
size={18}
|
|
strokeWidth={2}
|
|
/>,
|
|
);
|
|
const icon = screen.getByRole("img", { name: "Пример" });
|
|
expect(icon).toHaveAttribute("width", "18");
|
|
expect(icon).toHaveAttribute("height", "18");
|
|
expect(icon).toHaveAttribute("stroke-width", "2");
|
|
expect(icon).toHaveAttribute("stroke", "currentColor");
|
|
},
|
|
);
|
|
});
|