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
cdef
", contentAfter: 'ab
cd
ef
', }); }); test("should transform root", async () => {
await testEditor({
contentBefore: "ab
c",
contentAfter:
'
ab
c
', }); }); test("should keepab
c
', }); }); test("should keep multiple conecutiveab
c
', }); }); test("should transform complexab
c
dxxxe
f
', }); }); test("should transform complexab
c
f
g
', }); }); test("should not transform", async () => { await testEditor({ contentBefore: "
ab
c
ab
c
ab
c
d
ab
c
d
ab
c
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: 'abc
def
abc
def
ghi
abcdef
ghi