import { describe, expect, it } from "vitest";
import { canTransitionProposalStatus, getProposalStatusLabel, parseProposalStatus } from "@/lib/proposals/status";

describe("proposal status", () => {
  it("parses only valid statuses", () => {
    expect(parseProposalStatus("DRAFT")).toBe("DRAFT");
    expect(parseProposalStatus("SUBMITTED")).toBe("SUBMITTED");
    expect(parseProposalStatus("INVALID")).toBeNull();
  });

  it("validates allowed transitions", () => {
    expect(canTransitionProposalStatus("DRAFT", "IN_PROGRESS")).toBe(true);
    expect(canTransitionProposalStatus("IN_PROGRESS", "SUBMITTED")).toBe(true);
    expect(canTransitionProposalStatus("SUBMITTED", "DRAFT")).toBe(false);
    expect(canTransitionProposalStatus("ARCHIVED", "DRAFT")).toBe(false);
  });

  it("returns spanish labels", () => {
    expect(getProposalStatusLabel("DRAFT")).toBe("Borrador");
    expect(getProposalStatusLabel("IN_PROGRESS")).toBe("En progreso");
    expect(getProposalStatusLabel("SUBMITTED")).toBe("Enviada");
    expect(getProposalStatusLabel("ARCHIVED")).toBe("Archivada");
  });
});
