import { describe, expect, it } from "vitest";
import type { TguPlatform } from "../../model/tguTypes";
import { isOperationalPlatform, operationalSpacecraftIds } from "./tguTimelineMapper";

function platform(overrides: Partial<TguPlatform>): TguPlatform {
  return { id: "x", noradId: 1, status: "OPERATIONAL", ...overrides };
}

describe("isOperationalPlatform", () => {
  it("принимает только статус OPERATIONAL без учёта регистра и пробелов", () => {
    expect(isOperationalPlatform(platform({ status: "OPERATIONAL" }))).toBe(true);
    expect(isOperationalPlatform(platform({ status: " operational " }))).toBe(true);
    expect(isOperationalPlatform(platform({ status: "STANDBY" }))).toBe(false);
    expect(isOperationalPlatform(platform({ status: "LOST" }))).toBe(false);
    expect(isOperationalPlatform(platform({ status: null }))).toBe(false);
    expect(isOperationalPlatform(platform({ status: undefined }))).toBe(false);
  });
});

describe("operationalSpacecraftIds", () => {
  it("собирает norad-id в виде строк и пропускает платформы без norad-id", () => {
    const ids = operationalSpacecraftIds([
      platform({ noradId: 2 }),
      platform({ noradId: 30 }),
      platform({ noradId: null }),
      platform({ noradId: undefined })
    ]);
    expect(ids).toEqual(new Set(["2", "30"]));
  });
});
