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 } from "@testing-library/react";
import { describe, it, expect, vi } from "vitest";
import { ClusterPopupContent } from "./index";
// Mock dependencies
vi.mock("react-i18next", (importOriginal) => __awaiter(void 0, void 0, void 0, function* () {
    return (Object.assign(Object.assign({}, (yield importOriginal())), { useTranslation: () => ({
            t: (key) => `translated:${key}`,
        }) }));
}));
describe("ClusterPopupContent", () => {
    it("renders nothing if activeMarker is undefined", () => {
        const { queryByTestId } = render(React.createElement(ClusterPopupContent, null));
        expect(queryByTestId("cluster-popup-content")).toBeNull();
    });
    it("renders a list of markers when activeMarker is defined", () => {
        const activeMarker = {
            markers: [
                { id: "1", name: "Marker 1", latitude: 0, longitude: 0 },
                { id: "2", name: "Marker 2", latitude: 1, longitude: 1 },
            ],
        };
        const { getByTestId, getAllByTestId } = render(React.createElement(ClusterPopupContent, { activeMarker: activeMarker }));
        const container = getByTestId("cluster-popup-content");
        expect(container).toBeInTheDocument();
        const items = getAllByTestId("marker-popup-list-item");
        expect(items).toHaveLength(2);
        expect(items[0]).toHaveTextContent("Marker 1");
        expect(items[1]).toHaveTextContent("Marker 2");
    });
    it("calls handleMarkerClick with correct parameters when a marker is clicked", () => {
        const activeMarker = {
            markers: [
                { id: "1", name: "Marker 1", latitude: 0, longitude: 0 },
                { id: "2", name: "Marker 2", latitude: 1, longitude: 1 },
            ],
        };
        const handleMarkerSelectedMock = vi.fn();
        const { getByTestId } = render(React.createElement(ClusterPopupContent, { activeMarker: activeMarker, onMarkerSelected: handleMarkerSelectedMock }));
        const markerButton = getByTestId("marker-popup-item-button-1");
        markerButton.click();
        expect(handleMarkerSelectedMock).toHaveBeenCalledWith({
            id: "1",
            name: "Marker 1",
            latitude: 0,
            longitude: 0,
        });
    });
    it("calls onClose when closed", () => {
        const activeMarker = {
            markers: [
                { id: "1", name: "Marker 1", latitude: 0, longitude: 0 },
                { id: "2", name: "Marker 2", latitude: 1, longitude: 1 },
            ],
        };
        const onCloseMock = vi.fn();
        const { getByTestId } = render(React.createElement(ClusterPopupContent, { activeMarker: activeMarker, onClose: onCloseMock }));
        const closeButton = getByTestId("poi-popup-content-header-close-button");
        closeButton.click();
        expect(onCloseMock).toHaveBeenCalled();
    });
});
//# sourceMappingURL=index.test.js.map