import { render, screen } from "@testing-library/react";

import { IconOnlyAction } from "@/shared/ui/icon-only-action";

describe("IconOnlyAction", () => {
  test("has an accessible name and a tooltip without duplicating the name as description", () => {
    render(
      <IconOnlyAction label="새로고침">
        <span aria-hidden="true">R</span>
      </IconOnlyAction>,
    );

    const button = screen.getByRole("button", { name: "새로고침" });
    const tooltip = screen.getByRole("tooltip");

    expect(tooltip).toHaveTextContent("새로고침");
    expect(button).not.toHaveAccessibleDescription("새로고침");
    expect(button).not.toHaveAttribute("aria-describedby");
    expect(button).toHaveAttribute("type", "button");
  });
});
