// @vitest-environment jsdom import { describe, it, expect } from "vitest"; import { getSchema } from "@tiptap/core"; import { pubScriptExtensions, PubScriptSchema, createPubScriptEditor } from "@pubscript/editor"; describe("editor schema + instantiation", () => { it("getSchema returns valid schema", () => { console.log("PubScriptSchema nodes:", PubScriptSchema ? Object.keys(PubScriptSchema.nodes).join(",") : "UNDEFINED"); console.log("PubScriptSchema marks:", PubScriptSchema ? Object.keys(PubScriptSchema.marks).join(",") : "UNDEFINED"); expect(PubScriptSchema).toBeTruthy(); expect(PubScriptSchema.nodes.sceneBreak).toBeTruthy(); expect(PubScriptSchema.nodes.footnote).toBeTruthy(); expect(PubScriptSchema.nodes.footnoteArea).toBeTruthy(); expect(PubScriptSchema.nodes.characterMention).toBeTruthy(); }); it("getSchema(pubScriptExtensions) matches PubScriptSchema", () => { const s = getSchema(pubScriptExtensions); console.log("inline getSchema nodes:", Object.keys(s.nodes).join(",")); expect(s).toBeTruthy(); }); it("createPubScriptEditor does not throw", () => { let editor; try { editor = createPubScriptEditor(); console.log("editor created, schema defined:", !!editor?.schema); console.log("editor doc type:", editor?.state?.doc?.type?.name); } catch (e) { console.log("createPubScriptEditor THREW:", (e as Error).message); throw e; } expect(editor).toBeTruthy(); expect(editor.schema).toBeTruthy(); expect(editor.state.doc.type).toBeTruthy(); }); });