import { describe, test } from "@odoo/hoot"; import { testEditor } from "./_helpers/editor"; /** * content of the "init" sub suite in editor.test.js */ describe("No orphan inline elements compatibility mode", () => { test("should wrap inline node inside a p", async () => { await testEditor({ contentBefore: "

abc

def

orphan node", contentAfter: '

abc

def

orphan node

', }); }); test("should wrap inline node inside a p (2)", async () => { await testEditor({ contentBefore: "

ab

cd

ef

", contentAfter: '

ab

cd

ef

', }); }); test("should transform root
into

", async () => { await testEditor({ contentBefore: "ab
c", contentAfter: '

ab

c

', }); }); test("should keep
if necessary", async () => { await testEditor({ contentBefore: "ab

c", contentAfter: '

ab


c

', }); }); test("should keep multiple conecutive
if necessary", async () => { await testEditor({ contentBefore: "ab



c", contentAfter: '

ab




c

', }); }); test("should transform complex
", async () => { await testEditor({ contentBefore: 'ab
c
dxxxe
f', contentAfter: '

ab

c

dxxxe

f

', }); }); test("should transform complex
+ keep li ", async () => { await testEditor({ contentBefore: "ab
c f
g", contentAfter: '

ab

c

f

g

', }); }); test("should not transform
inside

", async () => { await testEditor({ contentBefore: "

ab
c

", contentAfter: "

ab
c

", }); await testEditor({ contentBefore: "

ab
c

d

", contentAfter: "

ab
c

d

", }); await testEditor({ contentBefore: "xx

ab
c

d
yy", contentAfter: '

xx

ab
c

d

yy

', }); }); test("should not transform indentation", async () => { await testEditor({ contentBefore: `

ab

c

`, contentAfter: `

ab

c

`, }); }); test("should transform root .fa", async () => { await testEditor({ contentBefore: '

ab

c

', contentAfter: '

ab

c

', }); }); test("should wrap a div.o_image direct child of the editable into a block", async () => { await testEditor({ contentBefore: '

abc

def

', contentBeforeEdit: '

abc

def

', contentAfter: '

abc

def

', }); }); }); describe("allowInlineAtRoot options", () => { test("should wrap inline node inside a p by default", async () => { await testEditor({ contentBefore: "abc", contentAfter: '

abc

', }); }); test("should wrap inline node inside a p if value is false", async () => { await testEditor( { contentBefore: "abc", contentAfter: '

abc

', }, { allowInlineAtRoot: false } ); }); test("should keep inline nodes unchanged if value is true", async () => { await testEditor({ contentBefore: "abc", contentAfter: "abc", config: { allowInlineAtRoot: true }, }); }); }); describe("sanitize spans/fonts", () => { test("should NOT sanitize attributeless spans away", async () => { await testEditor({ contentBefore: "

abc

", contentAfter: "

abc

", }); }); test("should NOT sanitize attributeless fonts away", async () => { await testEditor({ contentBefore: "

abc

", contentAfter: "

abc

", }); }); }); describe("list normalization", () => { test("should keep P in LI (regardless of class)", async () => { await testEditor({ contentBefore: '', contentAfter: '', }); }); test("should keep inlines in LI", async () => { await testEditor({ contentBefore: "", contentAfter: "", }); }); test("should wrap inlines in P to prevent mixing block and inline in LI", async () => { await testEditor({ contentBefore: "", contentAfter: "", }); }); });