import { describe, expect, it } from "vitest";
import {
  ARCH_SIZES,
  getArchNodeSize,
  resolveArchitectureNodeType,
  resolveArchitectureEdgeType,
} from "./constants";

describe("resolveArchitectureNodeType", () => {
  it("should resolve arch:service to archService", () => {
    expect(resolveArchitectureNodeType("arch:service")).toBe("archService");
  });

  it("should resolve arch:database to archDatabase", () => {
    expect(resolveArchitectureNodeType("arch:database")).toBe("archDatabase");
  });

  it("should resolve arch:queue to archQueue", () => {
    expect(resolveArchitectureNodeType("arch:queue")).toBe("archQueue");
  });

  it("should resolve arch:loadbalancer to archLoadBalancer", () => {
    expect(resolveArchitectureNodeType("arch:loadbalancer")).toBe(
      "archLoadBalancer",
    );
  });

  it("should resolve arch:external to archExternal", () => {
    expect(resolveArchitectureNodeType("arch:external")).toBe("archExternal");
  });

  it("should resolve bare type without prefix", () => {
    expect(resolveArchitectureNodeType("database")).toBe("archDatabase");
  });

  it("should default unknown types to archService", () => {
    expect(resolveArchitectureNodeType("arch:unknown")).toBe("archService");
    expect(resolveArchitectureNodeType("something")).toBe("archService");
  });
});

describe("resolveArchitectureEdgeType", () => {
  it("should always return archConnection", () => {
    expect(resolveArchitectureEdgeType("sync")).toBe("archConnection");
    expect(resolveArchitectureEdgeType("async")).toBe("archConnection");
    expect(resolveArchitectureEdgeType(undefined)).toBe("archConnection");
  });
});

describe("getArchNodeSize", () => {
  it("should return correct size for archService", () => {
    expect(getArchNodeSize("archService")).toEqual(ARCH_SIZES.service);
  });

  it("should return correct size for archDatabase", () => {
    expect(getArchNodeSize("archDatabase")).toEqual(ARCH_SIZES.database);
  });

  it("should return correct size for archQueue", () => {
    expect(getArchNodeSize("archQueue")).toEqual(ARCH_SIZES.queue);
  });

  it("should return correct size for archLoadBalancer", () => {
    expect(getArchNodeSize("archLoadBalancer")).toEqual(
      ARCH_SIZES.loadbalancer,
    );
  });

  it("should return correct size for archExternal", () => {
    expect(getArchNodeSize("archExternal")).toEqual(ARCH_SIZES.external);
  });

  it("should return null for non-architecture types", () => {
    expect(getArchNodeSize("erEntity")).toBeNull();
    expect(getArchNodeSize("bpmnActivity")).toBeNull();
    expect(getArchNodeSize(undefined)).toBeNull();
  });
});
