// @vitest-environment jsdom
import { describe, it, expect, vi } from "vitest";
import { render, screen } from "@testing-library/react";
import { OperatorLogo } from "./OperatorLogo.js";
import type { ISimpleFlight } from "../../types.js";

vi.mock("@/i18n/provider.js", () => ({
  useTranslation: () => ({ t: (k: string) => k }),
}));

function makeFlight(carrier: string): ISimpleFlight {
  return {
    id: "X", routeType: "Direct", flyingTime: "1h", status: "Scheduled",
    flightId: { carrier, flightNumber: "0022", suffix: "", date: "20260417" },
    operatingBy: { carrier, flightNumber: "0022" },
    leg: {} as never,
  } as ISimpleFlight;
}

describe("OperatorLogo", () => {
  it("renders with company-logo and company-logo--SU classes", () => {
    render(<OperatorLogo flight={makeFlight("SU")} locale="en" />);
    const el = screen.getByTestId("operator-logo");
    expect(el.className).toContain("company-logo");
    expect(el.className).toContain("company-logo--SU");
  });

  it("adds ru class when locale is ru", () => {
    render(<OperatorLogo flight={makeFlight("SU")} locale="ru" />);
    expect(screen.getByTestId("operator-logo").className).toContain("ru");
  });

  it("adds large class when large=true", () => {
    render(<OperatorLogo flight={makeFlight("SU")} locale="en" large />);
    expect(screen.getByTestId("operator-logo").className).toContain("large");
  });

  it("adds round class when round=true", () => {
    render(<OperatorLogo flight={makeFlight("SU")} locale="en" round />);
    expect(screen.getByTestId("operator-logo").className).toContain("round");
  });

  it("renders caption when caption=true", () => {
    render(<OperatorLogo flight={makeFlight("SU")} locale="en" caption />);
    expect(screen.getByText("SHARED.AVIACOMPANY")).toBeTruthy();
  });

  it("does not render caption by default", () => {
    render(<OperatorLogo flight={makeFlight("SU")} locale="en" />);
    expect(screen.queryByText("SHARED.AVIACOMPANY")).toBeNull();
  });
});
