import { describe, test } from "@odoo/hoot"; import { testEditor } from "./_helpers/editor"; import { unformat } from "./_helpers/format"; import { BOLD_TAGS } from "./_helpers/tags"; /** * content of the "init" sub suite in editor.test.js */ describe("No orphan inline elements compatibility mode", () => { test("should wrap inline node inside a div baseContainer", async () => { await testEditor({ contentBefore: "
abc
def
orphan node", contentAfter: "abc
def
ab
cdef
", contentAfter: "ab
ef
", }); }); test("should transform root", async () => { await testEditor({ contentBefore: "
ab
c
ab
c
ab
c
d
ab
c
d
ab
c
ab
c
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
", 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
parent child
`), contentAfter: unformat(`parentchild
`), }); }); test("should unwrap nested identical tags with color (class and style same)", async () => { await testEditor({ contentBefore: unformat(`parent child
`), contentAfter: unformat(`parentchild
`), }); }); test("should unwrap nested with same style but no class", async () => { await testEditor({ contentBefore: unformat(`parent child
`), contentAfter: unformat(`parentchild
`), }); }); test("should unwrap nested with same class only", async () => { await testEditor({ contentBefore: unformat(`parent child
`), contentAfter: unformat(`parentchild
`), }); }); test("should unwrap nested with no class or style", async () => { await testEditor({ contentBefore: unformat(`parent child
`), contentAfter: unformat(`parentchild
`), }); }); test("should unwrap nested with same style and class as closest ", async () => { await testEditor({ contentBefore: unformat(`parent text1 child text2
`), contentAfter: unformat(`parenttext1childtext2
`), }); }); }); describe("formatting normalization", () => { test("should unwrap nested identical bold tags", async () => { for (const tag of BOLD_TAGS) { await testEditor({ contentBefore: `a${tag(`b${tag(`c${tag(`d`)}`)}e`)}f
`, contentAfter: `a${tag("bcde")}f
`, }); } }); test("should merge nested strong inside formatting tags", async () => { await testEditor({ contentBefore: unformat(`
text1
text2
text3
text1text2text3