import { describe, expect, it } from "vitest";
import { evaluateSignaturePolicy } from "@/lib/compliance/signature-policy";

describe("evaluateSignaturePolicy", () => {
  it("returns conservative municipal rule for San Pedro", () => {
    const evaluation = evaluateSignaturePolicy({
      stateCode: "NL",
      municipalityName: "San Pedro Garza Garcia",
      documentType: "BASES_LICITACION",
    });

    expect(evaluation.policyStatus).toBe("requiere_validacion_legal");
    expect(evaluation.evidenceRequired.length).toBeGreaterThan(0);
  });

  it("returns conditioned rule for Nuevo Leon state scope", () => {
    const evaluation = evaluateSignaturePolicy({
      stateCode: "NL",
      municipalityName: "Monterrey",
      documentType: "CONVOCATORIA",
    });

    expect(evaluation.policyStatus).toBe("condicionado");
    expect(evaluation.policyName.toLowerCase()).toContain("firma electronica");
  });

  it("defaults to legal validation when jurisdiction is unknown", () => {
    const evaluation = evaluateSignaturePolicy({
      stateName: "Estado no configurado",
      municipalityName: "Municipio X",
    });

    expect(evaluation.policyStatus).toBe("requiere_validacion_legal");
  });
});
