import { describe, it, expect } from "vitest";
import { transformScoresMenuData } from "./index";
describe("transformScoresMenuData", () => {
    it("returns an object with empty categories if scoresMenu is undefined", () => {
        const result = transformScoresMenuData(undefined);
        expect(result.categories).toEqual([]);
    });
    it("filters out hidden categories", () => {
        const scoresMenu = {
            categories: {
                transport: { hide: true, order: 1, scores: {} },
                education: { hide: false, order: 2, scores: {} },
                amenities: { order: 3, scores: {} },
            },
        };
        const result = transformScoresMenuData(scoresMenu);
        const categoryKeys = result.categories.map(([key]) => key);
        expect(categoryKeys).toContain("education");
        expect(categoryKeys).toContain("amenities");
        expect(categoryKeys).not.toContain("transport");
    });
    it("sorts categories by order", () => {
        const scoresMenu = {
            categories: {
                education: { order: 2, scores: {} },
                transport: { order: 1, scores: {} },
                amenities: { scores: {} },
            },
        };
        const result = transformScoresMenuData(scoresMenu);
        const categoryKeys = result.categories.map(([key]) => key);
        expect(categoryKeys).toEqual(["amenities", "transport", "education"]);
    });
    it("filters out hidden scores within categories", () => {
        const scoresMenu = {
            categories: {
                transport: {
                    order: 1,
                    scores: {
                        pedestrian_friendly: { hide: true, order: 1 },
                        transit_friendly: { hide: false, order: 2 },
                        cycling_friendly: { order: 3 },
                    },
                },
            },
        };
        const result = transformScoresMenuData(scoresMenu);
        const scores = result.categories[0][1].scores.map(([key]) => key);
        expect(scores).toContain("transit_friendly");
        expect(scores).toContain("cycling_friendly");
        expect(scores).not.toContain("pedestrian_friendly");
    });
    it("sorts scores by order within each category", () => {
        const scoresMenu = {
            categories: {
                transport: {
                    order: 1,
                    scores: {
                        pedestrian_friendly: { order: 2 },
                        transit_friendly: { order: 1 },
                        cycling_friendly: {},
                    },
                },
            },
        };
        const result = transformScoresMenuData(scoresMenu);
        const scores = result.categories[0][1].scores.map(([key]) => key);
        expect(scores).toEqual([
            "cycling_friendly",
            "transit_friendly",
            "pedestrian_friendly",
        ]);
    });
    it("handles missing categories and scores gracefully", () => {
        const scoresMenu = {};
        const result = transformScoresMenuData(scoresMenu);
        expect(result.categories).toEqual([]);
    });
    it("preserves other properties of scoresMenu", () => {
        const scoresMenu = {
            foo: "bar",
            categories: {},
        };
        const result = transformScoresMenuData(scoresMenu);
        expect(result.foo).toBe("bar");
    });
});
//# sourceMappingURL=index.test.js.map