import { describe, expect, it } from "vitest";
import {
  MS_CARGO_TYPES,
  MS_DEFAULT_READY_TIME,
  MS_DELIVERY_ACCESSORIALS,
  MS_PICKUP_ACCESSORIALS,
  MS_READY_TIMES,
} from "@/components/mothership/mothership-logged-in-shipment-form";

describe("mothership logged-in shipment form constants", () => {
  it("提货附加服务含官网录制项", () => {
    const ids = MS_PICKUP_ACCESSORIALS.map((x) => x.id);
    expect(ids).toEqual(
      expect.arrayContaining([
        "cfs",
        "liftgate",
        "limitedAccess",
        "inside",
        "residential",
        "tradeshow",
      ]),
    );
  });

  it("送货附加服务含 Amazon 预约等录制项", () => {
    const ids = MS_DELIVERY_ACCESSORIALS.map((x) => x.id);
    expect(ids).toEqual(
      expect.arrayContaining([
        "fbaAppointment",
        "appointment",
        "cfs",
        "liftgate",
        "limitedAccess",
        "inside",
        "residential",
        "tradeshow",
      ]),
    );
  });

  it("货物类型对齐官网完整列表", () => {
    expect(MS_CARGO_TYPES.map((x) => x.id)).toEqual([
      "pallet",
      "box",
      "crate",
      "piece",
      "bale",
      "bucket",
      "carton",
      "case",
      "coil",
      "cylinder",
      "drum",
      "pail",
      "reel",
      "roll",
      "skid",
      "tote",
      "tube",
    ]);
  });

  it("可提货时刻为 24 个整点且有序无重复", () => {
    expect(MS_READY_TIMES).toHaveLength(24);
    expect(new Set(MS_READY_TIMES).size).toBe(24);
    expect(MS_READY_TIMES[0]).toBe("12:00 AM");
    expect(MS_READY_TIMES[11]).toBe("11:00 AM");
    expect(MS_READY_TIMES[12]).toBe("12:00 PM");
    expect(MS_READY_TIMES[15]).toBe("3:00 PM");
    expect(MS_READY_TIMES[23]).toBe("11:00 PM");
    expect(MS_DEFAULT_READY_TIME).toBe("11:00 AM");
    expect(MS_READY_TIMES).toContain(MS_DEFAULT_READY_TIME);
  });
});
