import { describe, expect, it } from "vitest";
import { outOfOrderInstructionWarning } from "./softWarnings";

describe("outOfOrderInstructionWarning", () => {
  it("returns null when there are no technical-approved measures", () => {
    expect(
      outOfOrderInstructionWarning({
        technicalApprovedMeasuresForInstall: null,
      }),
    ).toBeNull();
    expect(
      outOfOrderInstructionWarning({
        technicalApprovedMeasuresForInstall: "",
      }),
    ).toBeNull();
    expect(
      outOfOrderInstructionWarning({
        technicalApprovedMeasuresForInstall: undefined,
      }),
    ).toBeNull();
  });

  it("returns a non-empty warning when technical-approved measures exist", () => {
    const w = outOfOrderInstructionWarning({
      technicalApprovedMeasuresForInstall: "ASHP;Solar PV",
    });
    expect(typeof w).toBe("string");
    expect(w?.toLowerCase()).toContain("technical-approved");
    expect(w?.toLowerCase()).toContain("out of");
  });

  it("treats whitespace-only text as no measures", () => {
    expect(
      outOfOrderInstructionWarning({
        technicalApprovedMeasuresForInstall: "   ",
      }),
    ).toBeNull();
  });
});
