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

import { Spinner } from "./spinner";

describe("Spinner", () => {
  it("renders with icon slot and default aria-hidden semantics", () => {
    render(<Spinner data-testid="spinner" size="lg" tone="primary" />);

    const spinner = screen.getByTestId("spinner");

    expect(spinner).toHaveAttribute("data-slot", "icon");
    expect(spinner).toHaveAttribute("data-size", "lg");
    expect(spinner).toHaveAttribute("data-tone", "primary");
    expect(spinner).toHaveAttribute("aria-hidden", "true");
  });

  it("keeps an accessible label when one is provided", () => {
    render(<Spinner aria-label="Loading releases" />);

    expect(screen.getByLabelText("Loading releases")).not.toHaveAttribute("aria-hidden");
  });
});
