import { describe, it, expect } from "vitest";
import { HOVER_ACTIONS } from "./HoverAffordances";

describe("HOVER_ACTIONS text mapping", () => {
  it("transform should include node type and label", () => {
    const action = HOVER_ACTIONS.find((a) => a.key === "transform")!;
    expect(action.getText("Order", "process")).toBe(
      'Transform this process "Order" into ',
    );
  });

  it("split should include the node label", () => {
    const action = HOVER_ACTIONS.find((a) => a.key === "split")!;
    expect(action.getText("UserService", "service")).toBe(
      'Split "UserService" into ',
    );
  });

  it("merge should include the node label", () => {
    const action = HOVER_ACTIONS.find((a) => a.key === "merge")!;
    expect(action.getText("Database", "database")).toBe(
      'Merge "Database" with ',
    );
  });

  it("explain should include the node label", () => {
    const action = HOVER_ACTIONS.find((a) => a.key === "explain")!;
    expect(action.getText("Payment Gateway", "service")).toBe(
      'Explain this element: "Payment Gateway"',
    );
  });

  it("annotate should include the node label with trailing space", () => {
    const action = HOVER_ACTIONS.find((a) => a.key === "annotate")!;
    expect(action.getText("API Router", "service")).toBe(
      'Annotate "API Router": ',
    );
  });

  it("should have exactly 5 actions", () => {
    expect(HOVER_ACTIONS).toHaveLength(5);
  });

  it("each action should have key, icon, label, and getText", () => {
    for (const action of HOVER_ACTIONS) {
      expect(action.key).toBeTruthy();
      expect(action.icon).toBeTruthy();
      expect(action.label).toBeTruthy();
      expect(typeof action.getText).toBe("function");
    }
  });
});
