import { describe, expect, it } from "vitest";
import { buildInitialMindmapAssetRefreshPayload } from "./mindmap-initial-sync";

describe("buildInitialMindmapAssetRefreshPayload", () => {
  it("远端 createOnly 成功时返回文件树刷新 payload", () => {
    expect(
      buildInitialMindmapAssetRefreshPayload({
        ok: true,
        docId: "doc-1",
        mindmapId: "mind-1",
      }),
    ).toEqual({
      id: "mind-1",
      document_id: "doc-1",
      asset_type: "mindmap",
      file_name: "mindmap-mind-1.json",
      file_url: "/documents/doc-1/mindmap-mind-1.json",
    });
  });

  it("远端 createOnly 失败时不应伪造文件树刷新事件", () => {
    expect(
      buildInitialMindmapAssetRefreshPayload({
        ok: false,
        docId: "doc-1",
        mindmapId: "mind-1",
      }),
    ).toBeNull();
  });
});
