import { describe, it, expect, vi } from "vitest";
import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { HoverEditButton } from "../HoverEditButton";

describe("HoverEditButton", () => {
	it("fires onClick and exposes the default aria-label", async () => {
		const onClick = vi.fn();
		render(<HoverEditButton onClick={onClick} />);
		const button = screen.getByRole("button", { name: "Edit" });
		await userEvent.click(button);
		expect(onClick).toHaveBeenCalledTimes(1);
	});

	it("honors a custom label", () => {
		render(<HoverEditButton onClick={() => {}} label="Rename machine" />);
		expect(
			screen.getByRole("button", { name: "Rename machine" }),
		).toBeInTheDocument();
	});
});
