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 } from "vitest";
import { List } from "./index";
const onSelectCategoryMock = vi.fn();
const tMock = vi.fn((key, _options) => key);
vi.mock("react-i18next", (importOriginal) => __awaiter(void 0, void 0, void 0, function* () {
    return (Object.assign(Object.assign({}, (yield importOriginal())), { useTranslation: () => ({
            t: tMock,
        }) }));
}));
const useLocalContentMock = vi.fn(() => ({
    distanceUnit: "metric",
    onSelectCategory: onSelectCategoryMock,
}));
vi.mock("~/sdks/LocalContent/context", () => ({
    useLocalContent: () => useLocalContentMock(),
}));
vi.mock("@phosphor-icons/react", () => ({
    CaretRightIcon: ({ className }) => (React.createElement("span", { className: className }, "CaretRightIcon")),
}));
describe("List", () => {
    it("renders correctly", () => {
        render(React.createElement(List, { pois: [
                {
                    name: "Pizza Place",
                    lat: 0,
                    lng: 0,
                    country: "CA",
                    proximity: { linear_distance: 0 },
                },
                {
                    name: "Healthy Eatery",
                    lat: 0,
                    lng: 0,
                    country: "CA",
                    proximity: { linear_distance: 0 },
                },
            ] }));
        expect(screen.getByTestId("score-poi-list-content")).toBeInTheDocument();
        expect(screen.getByTestId("score-poi-list-title")).toBeInTheDocument();
        expect(screen.getByTestId("score-poi-list-content")).toBeInTheDocument();
        expect(screen.getAllByTestId("score-poi-list-name").length).toBe(2);
    });
    it("displays the correct title", () => {
        render(React.createElement(List, { pois: [
                {
                    name: "Pizza Place",
                    lat: 0,
                    lng: 0,
                    country: "CA",
                    proximity: { linear_distance: 0 },
                },
            ] }));
        expect(screen.getByTestId("score-poi-list-name")).toBeInTheDocument();
    });
    it("renders no items when pois are empty", () => {
        render(React.createElement(List, { pois: [] }));
        expect(screen.queryByTestId("score-poi-list")).not.toBeInTheDocument();
    });
    it("renders no items when the showPois prop is false", () => {
        render(React.createElement(List, { pois: [
                {
                    name: "Pizza Place",
                    lat: 0,
                    lng: 0,
                    country: "CA",
                    proximity: { linear_distance: 0 },
                },
                {
                    name: "Healthy Eatery",
                    lat: 0,
                    lng: 0,
                    country: "CA",
                    proximity: { linear_distance: 0 },
                },
            ], showPois: false }));
        expect(screen.queryByTestId("score-poi-list")).not.toBeInTheDocument();
    });
    it("renders multiple items correctly", () => {
        render(React.createElement(List, { pois: [
                {
                    name: "Pizza Place",
                    lat: 0,
                    lng: 0,
                    country: "CA",
                    proximity: { linear_distance: 0 },
                },
                {
                    name: "Healthy Eatery",
                    lat: 0,
                    lng: 0,
                    country: "CA",
                    proximity: { linear_distance: 0 },
                },
            ] }));
        expect(screen.getAllByTestId("score-poi-list-name").length).toBe(2);
    });
    it("displays the correct distance unit when metric", () => {
        useLocalContentMock.mockReturnValue({
            distanceUnit: "metric",
            onSelectCategory: onSelectCategoryMock,
        });
        render(React.createElement(List, { pois: [
                {
                    name: "Pizza Place",
                    lat: 0,
                    lng: 0,
                    country: "CA",
                    proximity: { linear_distance: 0 },
                },
            ] }));
        const title = screen.getByTestId("score-poi-list-title");
        expect(title).toBeInTheDocument();
        expect(tMock).toHaveBeenCalledWith("poiSearchRadius", {
            radius: "2.5",
            unit: "common:distance.kilometer",
        });
    });
    it("displays the correct distance unit when imperial", () => {
        useLocalContentMock.mockReturnValue({
            distanceUnit: "imperial",
            onSelectCategory: onSelectCategoryMock,
        });
        render(React.createElement(List, { pois: [
                {
                    name: "Pizza Place",
                    lat: 0,
                    lng: 0,
                    country: "CA",
                    proximity: { linear_distance: 0 },
                },
            ] }));
        const title = screen.getByTestId("score-poi-list-title");
        expect(title).toBeInTheDocument();
        expect(tMock).toHaveBeenCalledWith("poiSearchRadius", {
            radius: "1.6",
            unit: "common:distance.mile",
        });
    });
});
//# sourceMappingURL=index.test.js.map