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 { describe, it, expect, vi } from "vitest";
import { render, screen } from "@testing-library/react";
import { Header } 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, options) => {
                if (key === "header.title" && (options === null || options === void 0 ? void 0 : options.neighborhood)) {
                    return `Explore ${options.neighborhood}`;
                }
                if (key === "header.description") {
                    return "translated:header.description";
                }
                if (key === "header.titleNoNeighborhood") {
                    return "translated:header.titleNoNeighborhood";
                }
                return `translated:${key}`;
            },
        }) }));
}));
// Mock context
const mockUseLeadCapture = vi.fn();
vi.mock("~/sdks/LeadCapture/context", () => ({
    useLeadCapture: () => mockUseLeadCapture(),
}));
describe("Header", () => {
    beforeEach(() => {
        mockUseLeadCapture.mockReset();
    });
    it("renders correctly", () => {
        mockUseLeadCapture.mockReturnValue({
            addressLabel: "Back Bay, Boston, Massachusetts",
            isGeographyBased: "lat/lng",
        });
        render(React.createElement(Header, null));
        expect(screen.getByTestId("header")).toBeInTheDocument();
    });
    it("header has a title and description with full address for lat/lng based geography", () => {
        mockUseLeadCapture.mockReturnValue({
            addressLabel: "Back Bay, Boston, Massachusetts",
            isGeographyBased: "lat/lng",
        });
        render(React.createElement(Header, null));
        expect(screen.getByText("Explore Back Bay, Boston, Massachusetts")).toBeInTheDocument();
        expect(screen.getByText("translated:header.description")).toBeInTheDocument();
    });
    it("renders short version of geography-based address for geographyId", () => {
        mockUseLeadCapture.mockReturnValue({
            addressLabel: "Back Bay, Boston, Massachusetts",
            isGeographyBased: "geographyId",
        });
        render(React.createElement(Header, null));
        const title = screen.getByTestId("header-title");
        expect(title).toHaveTextContent("Explore Back Bay");
    });
    it("renders short version of geography-based address with no name or subcountry", () => {
        mockUseLeadCapture.mockReturnValue({
            addressLabel: "Boston",
            isGeographyBased: "geographyId",
        });
        render(React.createElement(Header, null));
        const title = screen.getByTestId("header-title");
        expect(title).toHaveTextContent("Explore Boston");
    });
    it("renders fallback title when no address label is provided", () => {
        mockUseLeadCapture.mockReturnValue({
            addressLabel: null,
            isGeographyBased: "lat/lng",
        });
        render(React.createElement(Header, null));
        const title = screen.getByTestId("header-title");
        expect(title).toHaveTextContent("translated:header.titleNoNeighborhood");
    });
});
//# sourceMappingURL=index.test.js.map