import { describe, it, expect } from "vitest";
import {
  SEQ_SIZES,
  SEQ_LAYOUT,
  resolveSequenceNodeType,
  resolveSequenceEdgeType,
  getSeqNodeSize,
} from "./constants";

describe("SEQ_SIZES", () => {
  it("should have participant dimensions", () => {
    expect(SEQ_SIZES.participant).toEqual({ w: 160, h: 60 });
  });

  it("should have fragment dimensions (computed dynamically)", () => {
    expect(SEQ_SIZES.fragment).toEqual({ w: 0, h: 0 });
  });
});

describe("SEQ_LAYOUT", () => {
  it("should have all layout constants", () => {
    expect(SEQ_LAYOUT.participantSpacing).toBe(200);
    expect(SEQ_LAYOUT.messageStartY).toBe(100);
    expect(SEQ_LAYOUT.messageSpacing).toBe(50);
    expect(SEQ_LAYOUT.lifelinePadding).toBe(40);
    expect(SEQ_LAYOUT.activationWidth).toBe(12);
    expect(SEQ_LAYOUT.fragmentPadding).toBe(16);
  });
});

describe("resolveSequenceNodeType", () => {
  it("should resolve seq:participant to seqParticipant", () => {
    expect(resolveSequenceNodeType("seq:participant")).toBe("seqParticipant");
  });

  it("should resolve seq:fragment to seqFragment", () => {
    expect(resolveSequenceNodeType("seq:fragment")).toBe("seqFragment");
  });

  it("should resolve bare participant to seqParticipant", () => {
    expect(resolveSequenceNodeType("participant")).toBe("seqParticipant");
  });

  it("should resolve bare fragment to seqFragment", () => {
    expect(resolveSequenceNodeType("fragment")).toBe("seqFragment");
  });

  it("should default unknown types to seqParticipant", () => {
    expect(resolveSequenceNodeType("unknown")).toBe("seqParticipant");
  });
});

describe("resolveSequenceEdgeType", () => {
  it("should resolve sync to seqSync", () => {
    expect(resolveSequenceEdgeType("sync")).toBe("seqSync");
  });

  it("should resolve async to seqAsync", () => {
    expect(resolveSequenceEdgeType("async")).toBe("seqAsync");
  });

  it("should resolve return to seqReturn", () => {
    expect(resolveSequenceEdgeType("return")).toBe("seqReturn");
  });

  it("should default undefined to seqSync", () => {
    expect(resolveSequenceEdgeType(undefined)).toBe("seqSync");
  });

  it("should default unknown types to seqSync", () => {
    expect(resolveSequenceEdgeType("unknown")).toBe("seqSync");
  });
});

describe("getSeqNodeSize", () => {
  it("should return participant size for seqParticipant", () => {
    expect(getSeqNodeSize("seqParticipant")).toEqual(SEQ_SIZES.participant);
  });

  it("should return null for non-sequence types", () => {
    expect(getSeqNodeSize("default")).toBeNull();
    expect(getSeqNodeSize("bpmnActivity")).toBeNull();
    expect(getSeqNodeSize(undefined)).toBeNull();
  });

  it("should return null for seqFragment (dynamically computed)", () => {
    expect(getSeqNodeSize("seqFragment")).toBeNull();
  });
});
