import React from "react";
import { render, screen } from "@testing-library/react";
import { describe, it, expect, vi, beforeEach } from "vitest";
import { ScoreComparison } from "./index";
// Mock ValueIndicator
vi.mock("./ValueIndicator", () => ({
    ValueIndicator: ({ comparison }) => (React.createElement("div", { "data-testid": "value-indicator" }, comparison)),
}));
// Mock useTranslation
const tMock = vi.fn();
vi.mock("react-i18next", () => ({
    useTranslation: () => ({
        t: tMock,
    }),
}));
vi.mock("~/sdks/LocalContent/context", () => ({
    useLocalContent: () => ({
        hideScoresList: [],
    }),
}));
describe("ScoreComparison", () => {
    beforeEach(() => {
        tMock.mockReset();
    });
    it("returns null if locationScoreValue is undefined", () => {
        const { container } = render(React.createElement(ScoreComparison, { comparedTo: {
                text: "score",
                value: 5,
            }, scoreKey: "pedestrian_friendly" }));
        expect(container.firstChild).toBeNull();
    });
    it("returns null if comparedTo is undefined", () => {
        const { container } = render(React.createElement(ScoreComparison, { locationScoreValue: 50, scoreKey: "pedestrian_friendly" }));
        expect(container.firstChild).toBeNull();
    });
    it("renders 'higher' comparison when locationScoreValue > comparedTo.value", () => {
        tMock.mockImplementation(() => "Higher than compared");
        render(React.createElement(ScoreComparison, { locationScoreValue: 80, comparedTo: {
                text: "score",
                value: 50,
            }, scoreKey: "pedestrian_friendly" }));
        expect(screen.getByTestId("score-comparison")).toBeInTheDocument();
        expect(screen.getByTestId("value-indicator")).toHaveTextContent("higher");
        expect(tMock).toHaveBeenCalledWith("scoreComparison.text", {
            context: "higher",
            name: "score",
            value: 50,
        });
        expect(screen.getByText("Higher than compared")).toBeInTheDocument();
    });
    it("renders 'lower' comparison when locationScoreValue < comparedTo.value", () => {
        tMock.mockImplementation(() => "Lower than compared");
        render(React.createElement(ScoreComparison, { locationScoreValue: 30, comparedTo: {
                text: "score",
                value: 60,
            }, scoreKey: "pedestrian_friendly" }));
        expect(screen.getByTestId("score-comparison")).toBeInTheDocument();
        expect(screen.getByTestId("value-indicator")).toHaveTextContent("lower");
        expect(tMock).toHaveBeenCalledWith("scoreComparison.text", {
            context: "lower",
            name: "score",
            value: 60,
        });
        expect(screen.getByText("Lower than compared")).toBeInTheDocument();
    });
    it("renders 'equal' comparison when locationScoreValue === comparedTo.value", () => {
        tMock.mockImplementation(() => "Equal to compared");
        render(React.createElement(ScoreComparison, { locationScoreValue: 70, comparedTo: {
                text: "score",
                value: 70,
            }, scoreKey: "pedestrian_friendly" }));
        expect(screen.getByTestId("score-comparison")).toBeInTheDocument();
        expect(screen.getByTestId("value-indicator")).toHaveTextContent("equal");
        expect(tMock).toHaveBeenCalledWith("scoreComparison.text", {
            context: undefined,
            name: "score",
            value: 70,
        });
        expect(screen.getByText("Equal to compared")).toBeInTheDocument();
    });
});
//# sourceMappingURL=index.test.js.map