import React from "react";
import { render, fireEvent } from "@testing-library/react";
import { vi } from "vitest";
import { CloseButton } from "./index";
// Mock the context to provide the onSelectScore function
const onSelectScoreMock = vi.fn();
vi.mock("../../context", () => ({
    useRootElement: () => ({
        onSelectScore: onSelectScoreMock,
    }),
}));
// Mock translations
const tMock = vi.fn();
vi.mock("react-i18next", () => ({
    useTranslation: () => ({
        t: tMock,
    }),
}));
describe("CloseButton", () => {
    beforeEach(() => {
        vi.resetAllMocks();
    });
    it("renders without crashing", () => {
        const { getByRole } = render(React.createElement(CloseButton, null));
        expect(getByRole("button")).toBeInTheDocument();
    });
    it("calls onSelectScore with null when clicked", () => {
        const { getByRole } = render(React.createElement(CloseButton, null));
        const button = getByRole("button");
        fireEvent.click(button);
        expect(onSelectScoreMock).toHaveBeenCalledWith(null);
    });
    it("is accessible by keyboard", () => {
        const { getByRole } = render(React.createElement(CloseButton, null));
        getByRole("button").focus();
        expect(document.activeElement).toBe(getByRole("button"));
    });
});
//# sourceMappingURL=index.test.js.map