var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
import React from "react";
import { render, screen } from "@testing-library/react";
import { describe, it, expect, vi, beforeEach } from "vitest";
import { ScoreDetails } from "./index";
vi.mock("react-i18next", (importOriginal) => __awaiter(void 0, void 0, void 0, function* () {
    return (Object.assign(Object.assign({}, (yield importOriginal())), { useTranslation: () => ({
            t: (key) => key,
        }) }));
}));
// Mock Score component
vi.mock("~/sdks/LocalContent/components/Score", () => ({
    Score: ({ scoreKey, scoreValue }) => (React.createElement("div", { "data-testid": "mock-header" },
        scoreKey,
        ":",
        scoreValue)),
}));
// Mock context hooks
const mockUseRootElement = vi.fn();
vi.mock("../context", () => ({
    useRootElement: () => mockUseRootElement(),
}));
vi.mock("~/sdks/LocalContent/context", () => ({
    useLocalContent: () => ({
        handleSelectPoiSubcategory: vi.fn(),
    }),
}));
describe("ScoreDetails", () => {
    beforeEach(() => {
        vi.resetAllMocks();
    });
    it("renders nothing if activeScoreData is undefined", () => {
        mockUseRootElement.mockReturnValue({
            isExpanded: true,
            isMarkersLoading: false,
            markersData: [],
            activeScore: "score1",
            activeScoreData: undefined,
        });
        render(React.createElement(ScoreDetails, null));
        expect(screen.getByTestId("sidebar-score-details")).toBeInTheDocument();
        expect(screen.queryByTestId("score-description")).toBeNull();
    });
    it("renders nothing if activeScore is undefined", () => {
        mockUseRootElement.mockReturnValue({
            isExpanded: true,
            isMarkersLoading: false,
            markersData: [],
            activeScore: undefined,
            activeScoreData: undefined,
        });
        render(React.createElement(ScoreDetails, null));
        expect(screen.getByTestId("sidebar-score-details")).toBeInTheDocument();
        expect(screen.queryByTestId("score-description")).toBeNull();
    });
    it("renders score details with correct score value", () => {
        mockUseRootElement.mockReturnValue({
            isExpanded: true,
            isMarkersLoading: false,
            markersData: [],
            activeScore: "score1",
            activeScoreData: {
                value: "4.56",
            },
        });
        render(React.createElement(ScoreDetails, null));
        expect(screen.getByTestId("sidebar-score-details")).toBeInTheDocument();
        expect(screen.getByTestId("mock-header").textContent).toBe("score1:4.56");
    });
    it("renders score details with correct metro score comparison", () => {
        mockUseRootElement.mockReturnValue({
            isExpanded: true,
            isMarkersLoading: false,
            markersData: [],
            activeScore: "score1",
            activeScoreData: {
                value: "4.56",
                geographies: { g30: { text: "G30 Score", value: 5 } },
            },
        });
        render(React.createElement(ScoreDetails, null));
        expect(screen.getByTestId("sidebar-score-details")).toBeInTheDocument();
        expect(screen.getByTestId("score-comparison")).toBeInTheDocument();
    });
    it("renders score details with correct score description", () => {
        mockUseRootElement.mockReturnValue({
            isExpanded: true,
            isMarkersLoading: false,
            markersData: [],
            activeScore: "score1",
            activeScoreData: {
                text: "Score description",
            },
        });
        render(React.createElement(ScoreDetails, null));
        expect(screen.getByTestId("sidebar-score-details")).toBeInTheDocument();
        expect(screen.getByTestId("score-description").textContent).toBe("Score description");
    });
    it("renders empty description if text is undefined", () => {
        mockUseRootElement.mockReturnValue({
            isExpanded: true,
            isMarkersLoading: false,
            markersData: [],
            activeScore: "score3",
            activeScoreData: { value: "2.5" },
        });
        render(React.createElement(ScoreDetails, null));
        expect(screen.getByTestId("sidebar-score-details")).toBeInTheDocument();
        expect(screen.queryByTestId("score-description")).toBeNull();
    });
});
//# sourceMappingURL=index.test.js.map