import { describe, it, expect, vi } from "vitest";
import { act, renderHook } from "@testing-library/react";
import { useScoreSelection } from "./index";
vi.mock("~/features/clientLibrary/useScores", () => ({
    useScores: vi.fn(() => ({
        data: {
            location: {
                shopping: { value: 5, text: "Shopping" },
                pedestrian_friendly: { value: 3, text: "Pedestrian friendly" },
            },
            geographies: [
                {
                    geog_id: "g10_1",
                },
                {
                    geog_id: "g30_2",
                    name: "G30 Score",
                    scores: { shopping: { value: 4 }, pedestrian_friendly: { value: 2 } },
                },
            ],
        },
        isFetching: false,
    })),
}));
describe("useScoreSelection", () => {
    beforeEach(() => {
        vi.resetAllMocks();
    });
    it("should initialize with null active score and category", () => {
        const { result } = renderHook(() => useScoreSelection({
            scoresMenu: {
                categories: [],
            },
            lat: 0,
            lng: 0,
        }));
        expect(result.current.activeScore).toBeNull();
        expect(result.current.activeCategory).toBeNull();
    });
    it("should fetch scores data and transform it correctly", () => {
        const { result } = renderHook(() => useScoreSelection({
            scoresMenu: {
                categories: [
                    ["amenities", { scores: [["shopping", {}]] }],
                    ["transport", { scores: [["pedestrian_friendly", {}]] }],
                ],
            },
            lat: 0,
            lng: 0,
        }));
        expect(result.current.scoresData).toEqual({
            shopping: {
                text: "Shopping",
                value: 10,
                geographies: {
                    g30: { text: "G30 Score", value: 8 },
                },
                categoryKey: "amenities",
                categoryOptions: { scores: [["shopping", {}]] },
            },
            pedestrian_friendly: {
                text: "Pedestrian friendly",
                value: 6,
                geographies: {
                    g30: { text: "G30 Score", value: 4 },
                },
                categoryKey: "transport",
                categoryOptions: { scores: [["pedestrian_friendly", {}]] },
            },
        });
    });
    it("should handle selecting a score and updating active state", () => {
        const { result } = renderHook(() => useScoreSelection({
            scoresMenu: {
                categories: [
                    ["amenities", { scores: [["shopping", {}]] }],
                    ["transport", { scores: [["pedestrian_friendly", {}]] }],
                ],
            },
            lat: 0,
            lng: 0,
        }));
        act(() => {
            result.current.handleSelectScore("shopping")();
        });
        expect(result.current.activeScore).toBe("shopping");
    });
    it("should update active category when a score is selected", () => {
        const { result } = renderHook(() => useScoreSelection({
            scoresMenu: {
                categories: [
                    ["amenities", { scores: [["shopping", {}]] }],
                    ["transport", { scores: [["pedestrian_friendly", {}]] }],
                ],
            },
            lat: 0,
            lng: 0,
        }));
        act(() => {
            result.current.handleSelectCategory("amenities")();
        });
        expect(result.current.activeCategory).toBe("amenities");
    });
});
//# sourceMappingURL=index.test.js.map