import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { Checkbox } from "./checkbox";

describe("Checkbox Component", () => {
  it("adds a fallback id for browser autofill diagnostics", () => {
    render(<Checkbox aria-label="Select row" />);

    expect(screen.getByRole("checkbox")).toHaveAttribute("id");
  });

  it("keeps explicit id and name values", () => {
    render(<Checkbox id="explicit-checkbox" name="explicit-name" />);
    const checkbox = screen.getByRole("checkbox");

    expect(checkbox).toHaveAttribute("id", "explicit-checkbox");
    expect(checkbox).toHaveAttribute("name", "explicit-name");
  });
});
