import React from "react";
import { render, screen } from "@testing-library/react";
import { describe, it, expect, vi } from "vitest";
import { Subcategories } from "./index";
const onSelectCategoryMock = vi.fn();
vi.mock("react-i18next", () => ({
    useTranslation: () => ({
        t: (key) => key,
    }),
}));
vi.mock("~/components/PoiIconDeprecated", () => ({
    PoiIcon: ({ type }) => React.createElement("div", null, type),
}));
describe("Subcategories", () => {
    it("displays subcategories when available", () => {
        render(React.createElement(Subcategories, { availablePoiSubcategories: ["restaurants", "healthy_restaurants"], scoreKey: "restaurants", selectedSubcategory: null, onSelectCategory: onSelectCategoryMock }));
        expect(screen.getByTestId("score-poi-list-subcategory-restaurants")).toBeInTheDocument();
        expect(screen.getByTestId("score-poi-list-subcategory-healthy_restaurants")).toBeInTheDocument();
    });
    // it("calls onSelectCategory when a subcategory is clicked", () => {
    //   const pois = {
    //     restaurants: [
    //       {
    //         name: "Pizza Place",
    //         lat: 0,
    //         lng: 0,
    //         country: "CA",
    //         proximity: { linear_distance: 0 },
    //       },
    //     ],
    //   };
    //   render(
    //     <Subcategories
    //       pois={pois}
    //       scoreKey={"restaurants"}
    //       selectedSubcategory={"restaurants"}
    //       onSelectCategory={onSelectCategoryMock}
    //     />
    //   );
    //   const button = screen.getByTestId("score-poi-list-subcategory-restaurants");
    //   button.click();
    //   expect(onSelectCategoryMock).toHaveBeenCalledWith("restaurants");
    // });
    it("does not display subcategories when none are available", () => {
        render(React.createElement(Subcategories, { availablePoiSubcategories: [], scoreKey: "restaurants", selectedSubcategory: "restaurants", onSelectCategory: onSelectCategoryMock }));
        expect(screen.queryByTestId("score-poi-list-subcategories-title")).not.toBeInTheDocument();
        expect(screen.queryByTestId("score-poi-list-subcategories-list")).not.toBeInTheDocument();
    });
    it("does not display subcategories when undefined", () => {
        render(React.createElement(Subcategories
        // @ts-expect-error Testing undefined case
        , { 
            // @ts-expect-error Testing undefined case
            availablePoiSubcategories: undefined, scoreKey: "restaurants", selectedSubcategory: "restaurants", onSelectCategory: onSelectCategoryMock }));
        expect(screen.queryByTestId("score-poi-list-subcategories-title")).not.toBeInTheDocument();
        expect(screen.queryByTestId("score-poi-list-subcategories-list")).not.toBeInTheDocument();
    });
    it("does not display subcategories when only one is available", () => {
        render(React.createElement(Subcategories, { availablePoiSubcategories: ["restaurants"], scoreKey: "restaurants", selectedSubcategory: "restaurants", onSelectCategory: onSelectCategoryMock }));
        expect(screen.queryByTestId("score-poi-list-subcategories-title")).not.toBeInTheDocument();
        expect(screen.queryByTestId("score-poi-list-subcategories-list")).not.toBeInTheDocument();
    });
});
//# sourceMappingURL=index.test.js.map