ultisuite-client/lib/drive/richtext-content.test.ts
R3D347HR4Y 303b2b1074
Some checks are pending
E2E / Playwright e2e (push) Waiting to run
wow
2026-06-11 01:22:40 +02:00

34 lines
1.0 KiB
TypeScript

import assert from "node:assert/strict"
import { describe, it } from "node:test"
import { ensureMinimalTipTapDoc, isEmptyTipTapDoc } from "./richtext-content.ts"
describe("richtext-content", () => {
it("detects empty TipTap documents", () => {
assert.equal(isEmptyTipTapDoc(undefined), true)
assert.equal(
isEmptyTipTapDoc({ type: "doc", content: [{ type: "paragraph" }] }),
true
)
assert.equal(
isEmptyTipTapDoc({
type: "doc",
content: [{ type: "paragraph", content: [{ type: "text", text: "Hello" }] }],
}),
false
)
})
it("ensureMinimalTipTapDoc fills missing blocks", () => {
assert.deepEqual(ensureMinimalTipTapDoc(undefined), {
type: "doc",
content: [{ type: "paragraph" }],
})
assert.deepEqual(ensureMinimalTipTapDoc({ type: "doc", content: [] }), {
type: "doc",
content: [{ type: "paragraph" }],
})
const existing = { type: "doc", content: [{ type: "paragraph" }] }
assert.equal(ensureMinimalTipTapDoc(existing), existing)
})
})