import React from "react";
import { render, screen } from "@testing-library/react";
import { describe, it, expect, vi, beforeEach } from "vitest";
import { Score } from "./index";
// Mock dependencies
vi.mock("react-i18next", () => ({
    useTranslation: () => ({
        t: (key) => key,
    }),
}));
vi.mock("~/sdks/LocalContent/components/ScoreValue", () => ({
    ScoreValue: ({ value }) => (React.createElement("span", { "data-testid": "score-value" }, value)),
}));
vi.mock("@local-logic/design-system", () => ({
    ColorIcon: ({ element, backgroundColor, fillColor }) => (React.createElement("span", { "data-testid": "color-icon", "data-background-color": backgroundColor, "data-fill-color": fillColor },
        element,
        backgroundColor,
        fillColor)),
}));
vi.mock("~/components/ScoreIcon", () => ({
    ScoreIcon: ({ score }) => (React.createElement("span", { "data-testid": "score-icon" }, score)),
}));
describe("Score", () => {
    beforeEach(() => {
        vi.resetAllMocks();
    });
    it("renders null if scoreKey is null", () => {
        const { container } = render(React.createElement(Score, { scoreKey: null, scoreValue: 10 }));
        expect(container.firstChild).toBeNull();
    });
    it("renders score with correct scoreKey and value", () => {
        render(React.createElement(Score, { scoreKey: "pedestrian_friendly", scoreValue: 10 }));
        expect(screen.getByTestId("score-component")).toBeInTheDocument();
        expect(screen.getByTestId("score-value")).toHaveTextContent("10");
        expect(screen.getByTestId("score-icon")).toHaveTextContent("pedestrian_friendly");
        expect(screen.getByText("common:scores.pedestrian_friendly.title")).toBeInTheDocument();
    });
    it("renders ScoreValue with undefined if scoreValue is not provided", () => {
        render(React.createElement(Score, { scoreKey: "pedestrian_friendly" }));
        expect(screen.getByTestId("score-value")).toHaveTextContent("");
    });
    it("passes correct colors to ColorIcon", () => {
        const { getByTestId } = render(React.createElement(Score, { scoreKey: "transit_friendly", scoreValue: 5, backgroundColor: "customBg", fillColor: "customFill" }));
        const icon = getByTestId("color-icon");
        expect(icon).toHaveAttribute("data-background-color", "customBg");
        expect(icon).toHaveAttribute("data-fill-color", "customFill");
    });
});
//# sourceMappingURL=index.test.js.map