Files

22 lines
756 B
TypeScript

// @vitest-environment jsdom
import "@testing-library/jest-dom/vitest";
import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { Checkbox } from ".";
describe("Checkbox accessibility wrapper", () => {
it("keeps a hidden string label as the checkbox accessible name", () => {
render(<Checkbox hideLabel label="Accept privacy policy" />);
expect(screen.getByRole("checkbox", { name: "Accept privacy policy" })).toBeInTheDocument();
});
it("preserves an explicit accessible name", () => {
render(<Checkbox hideLabel label="Privacy" aria-label="Accept privacy policy" />);
expect(screen.getByRole("checkbox", { name: "Accept privacy policy" })).toBeInTheDocument();
});
});