// @vitest-environment jsdom
import { describe, it, expect } from "vitest";
import { render, screen } from "@testing-library/react";
import { TransferTime } from "./TransferTime.js";

describe("TransferTime", () => {
  it("renders '1h 30m' for valid inputs", () => {
    render(<TransferTime arrivalUtc="2026-04-17T10:00:00Z" departureUtc="2026-04-17T11:30:00Z" />);
    expect(screen.getByText("1h 30m")).toBeTruthy();
  });

  it("returns null when arrivalUtc is empty string", () => {
    const { container } = render(<TransferTime arrivalUtc="" departureUtc="2026-04-17T11:30:00Z" />);
    expect(container.firstChild).toBeNull();
  });

  it("returns null when departure is before arrival", () => {
    const { container } = render(
      <TransferTime arrivalUtc="2026-04-17T12:00:00Z" departureUtc="2026-04-17T11:00:00Z" />,
    );
    expect(container.firstChild).toBeNull();
  });
});
