var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import React from "react";
import { render } from "@testing-library/react";
import { vi } from "vitest";
import { Score } from "./index";
vi.mock("~/tracking", () => ({
    useTracking: () => ({
        postEvent: vi.fn(),
        trackAnalyticsEvent: vi.fn(),
    }),
}));
// Mock translations
vi.mock("react-i18next", () => ({
    useTranslation: () => ({
        t: (key) => key,
    }),
}));
vi.mock("~/components/ScoreIcon", () => ({
    ScoreIcon: ({ score }) => (React.createElement("div", { "data-testid": "score-icon" }, score)),
}));
vi.mock("~/sdks/LocalContent/components/ItemButton", () => ({
    ItemButton: (_a) => {
        var { isDisabled, isCollapsed = false, isActive = false, icon: { element: Icon, backgroundColor = "gray", fillColor = "black" }, onClick } = _a, rest = __rest(_a, ["isDisabled", "isCollapsed", "isActive", "icon", "onClick"]);
        return (React.createElement("button", Object.assign({ disabled: isDisabled, onClick: onClick, "data-icon-element": Icon, "data-icon-background-color": backgroundColor, "data-icon-fill-color": fillColor, "data-is-collapsed": isCollapsed, "data-is-active": isActive }, rest)));
    },
}));
// Mock context
const mockUseRootElement = vi.fn();
vi.mock("../context", () => ({
    useRootElement: () => mockUseRootElement(),
}));
describe("Score component", () => {
    const defaultProps = {
        scoreKey: "pedestrian_friendly",
        backgroundColor: "#fff",
        fillColor: "#000",
    };
    beforeEach(() => {
        vi.resetAllMocks();
    });
    it("renders without crashing", () => {
        mockUseRootElement.mockReturnValue({
            isExpanded: true,
            activeScore: null,
            onSelectScore: vi.fn(),
        });
        const { getByTestId } = render(React.createElement(Score, Object.assign({}, defaultProps)));
        expect(getByTestId("sidebar-score-item")).toBeInTheDocument();
    });
    // it("calls onSelectScore when clicked", () => {
    //   const onSelectScoreMock = vi.fn();
    //   mockUseRootElement.mockReturnValue({
    //     isExpanded: true,
    //     activeScore: null,
    //     onSelectScore: onSelectScoreMock,
    //   });
    //   const { getByTestId } = render(<Score {...defaultProps} />);
    //   const button = getByTestId("sidebar-score-item");
    //   fireEvent.click(button);
    //   expect(onSelectScoreMock).toHaveBeenCalledWith("pedestrian_friendly");
    // });
    it("applies background and fill colors", () => {
        mockUseRootElement.mockReturnValue({
            isExpanded: true,
            activeScore: null,
            onSelectScore: vi.fn(),
        });
        const { getByTestId } = render(React.createElement(Score, Object.assign({}, defaultProps, { backgroundColor: "#f00", fillColor: "#0f0" })));
        const button = getByTestId("sidebar-score-item");
        expect(button).toHaveAttribute("data-icon-background-color", "#f00");
        expect(button).toHaveAttribute("data-icon-fill-color", "#0f0");
    });
    it("is disabled when isExpanded is false", () => {
        mockUseRootElement.mockReturnValue({
            isExpanded: false,
            activeScore: null,
            onSelectScore: vi.fn(),
        });
        const { getByTestId } = render(React.createElement(Score, Object.assign({}, defaultProps)));
        const button = getByTestId("sidebar-score-item");
        expect(button).toBeDisabled();
    });
    it("is active when activeScore matches scoreKey", () => {
        mockUseRootElement.mockReturnValue({
            isExpanded: true,
            activeScore: "pedestrian_friendly",
            onSelectScore: vi.fn(),
        });
        const { getByTestId } = render(React.createElement(Score, Object.assign({}, defaultProps)));
        const button = getByTestId("sidebar-score-item");
        expect(button).toHaveAttribute("data-is-active", "true");
    });
    it("is collapsed when isExpanded is false", () => {
        mockUseRootElement.mockReturnValue({
            isExpanded: false,
            activeScore: "pedestrian_friendly",
            onSelectScore: vi.fn(),
        });
        const { getByTestId } = render(React.createElement(Score, Object.assign({}, defaultProps)));
        const button = getByTestId("sidebar-score-item");
        expect(button).toHaveAttribute("data-is-collapsed", "true");
    });
    it("renders with default colors when none are provided", () => {
        mockUseRootElement.mockReturnValue({
            isExpanded: true,
            activeScore: "pedestrian_friendly",
            onSelectScore: vi.fn(),
        });
        const { getByTestId } = render(React.createElement(Score, { scoreKey: "pedestrian_friendly" }));
        const button = getByTestId("sidebar-score-item");
        expect(button).toHaveAttribute("data-icon-background-color", "gray");
        expect(button).toHaveAttribute("data-icon-fill-color", "black");
    });
});
//# sourceMappingURL=index.test.js.map