import React from "react";
import { vi } from "vitest";
import { render } from "@testing-library/react";
import { Attribution } from "./index";
vi.mock("react-i18next", () => ({
    useTranslation: () => ({
        t: (key) => key,
    }),
}));
vi.mock("~/assets/images/logo.svg", () => ({
    default: () => React.createElement("div", { "data-testid": "logo" }, "Logo"),
}));
describe("Attribution", () => {
    it("renders the attribution link with correct href", () => {
        const { getByTestId } = render(React.createElement(Attribution, { sdkName: "test-sdk" }));
        const linkElement = getByTestId("attribution-link");
        expect(linkElement).toBeInTheDocument();
        expect(linkElement).toHaveTextContent("common:attribution");
        expect(getByTestId("logo")).toBeInTheDocument();
    });
    it("renders the attribution link with correct content", () => {
        const { getByTestId } = render(React.createElement(Attribution, { sdkName: "test-sdk" }));
        const linkElement = getByTestId("attribution-link");
        expect(linkElement).toBeInTheDocument();
        expect(linkElement).toHaveAttribute("href", "https://locallogic.co/?utm_source=unknown&utm_medium=referral&utm_campaign=test-sdk");
    });
    it("renders the attribution link with correct content when locale is fr", () => {
        const { getByTestId } = render(React.createElement(Attribution, { sdkName: "test-sdk", locale: "fr" }));
        const linkElement = getByTestId("attribution-link");
        expect(linkElement).toBeInTheDocument();
        expect(linkElement).toHaveAttribute("href", "https://locallogic.co/fr/?utm_source=unknown&utm_medium=referral&utm_campaign=test-sdk");
    });
    it("handles missing sdkName and locale gracefully", () => {
        const { getByTestId } = render(React.createElement(Attribution, null));
        const linkElement = getByTestId("attribution-link");
        expect(linkElement).toBeInTheDocument();
        expect(linkElement).toHaveAttribute("href", "https://locallogic.co/?utm_source=unknown&utm_medium=referral&utm_campaign=unknown-sdk");
    });
    it("applies the transparent style when isTransparent is true", () => {
        const { getByTestId } = render(React.createElement(Attribution, { sdkName: "test-sdk", isTransparent: true }));
        const linkElement = getByTestId("attribution-link");
        expect(linkElement).toHaveAttribute("data-is-transparent", "true");
    });
    it("opens the link in a new tab", () => {
        const { getByTestId } = render(React.createElement(Attribution, { sdkName: "test-sdk" }));
        const linkElement = getByTestId("attribution-link");
        expect(linkElement).toHaveAttribute("target", "_blank");
        expect(linkElement).toHaveAttribute("rel", "noreferrer");
    });
    it("calls onClick handler when provided", () => {
        const onClickMock = vi.fn();
        const { getByTestId } = render(React.createElement(Attribution, { sdkName: "test-sdk", onClick: onClickMock }));
        const linkElement = getByTestId("attribution-link");
        linkElement.click();
        expect(onClickMock).toHaveBeenCalled();
    });
    it("does not render when isHidden is true", () => {
        const { queryByTestId } = render(React.createElement(Attribution, { sdkName: "test-sdk", isHidden: true }));
        const linkElement = queryByTestId("attribution-link");
        expect(linkElement).toBeNull();
    });
});
//# sourceMappingURL=index.test.js.map