import { describe, expect, it } from "vitest";
import { evaluateMotherShipAddressChipLines } from "@/workers/rpa/address-chip-visual";

describe("evaluateMotherShipAddressChipLines", () => {
  it("截图态：门牌行 + City, ST 两行 → 已确认", () => {
    const lines = [
      "Where to?",
      "1234 Warehouse Street",
      "Los Angeles, CA",
      "Deliver to",
      "Freight details",
    ];
    const probe = evaluateMotherShipAddressChipLines(
      lines,
      "1234",
      "Los Angeles",
    );
    expect(probe.committed).toBe(true);
    expect(probe.streetLine).toBe("1234 Warehouse Street");
    expect(probe.cityLine).toBe("Los Angeles, CA");
  });

  it("打字态：整段查询在同一行 → 未确认", () => {
    const lines = [
      "1234 Warehouse Street, Los Angeles, California",
      "Deliver to",
    ];
    expect(
      evaluateMotherShipAddressChipLines(lines, "1234", "Los Angeles")
        .committed,
    ).toBe(false);
  });

  it("仅 City, ST 无门牌行 → 未确认", () => {
    const lines = ["Los Angeles, CA", "Deliver to"];
    expect(
      evaluateMotherShipAddressChipLines(lines, "1234", "Los Angeles")
        .committed,
    ).toBe(false);
  });
});
