import {
  DEFAULT_EDITOR_HOST_KIND,
  normalizeEditorHostKind,
  resolveEditorHostKind,
} from "@/components/editor/editor-host-config";
import { describe, expect, it } from "vitest";

describe("editor-host-config", () => {
  it("保持 island 为默认正式 host", () => {
    expect(DEFAULT_EDITOR_HOST_KIND).toBe("leptos_tiptap_island");
  });

  it("将 inline 和旧 runtime 兼容别名收敛到正式 island host", () => {
    expect(normalizeEditorHostKind("leptos_tiptap_inline")).toBe("leptos_tiptap_island");
    expect(normalizeEditorHostKind("leptos_tiptap_runtime")).toBe("leptos_tiptap_island");
    expect(normalizeEditorHostKind("leptos_tiptap")).toBe("leptos_tiptap_island");
  });

  it("保留 iframe debug 作为显式调试 host", () => {
    expect(normalizeEditorHostKind("leptos_tiptap_iframe_debug")).toBe(
      "leptos_tiptap_iframe_debug",
    );
    expect(normalizeEditorHostKind("iframe_debug")).toBe("leptos_tiptap_iframe_debug");
    expect(normalizeEditorHostKind("leptos_tiptap_debug")).toBe(
      "leptos_tiptap_iframe_debug",
    );
  });

  it("优先尊重 query override 的 debug host 选择", () => {
    expect(
      resolveEditorHostKind({
        override: "leptos_tiptap_iframe_debug",
        runtimeDefault: "leptos_tiptap_island",
      }),
    ).toBe("leptos_tiptap_iframe_debug");
  });
});
