import { describe, test } from "@odoo/hoot"; import { testEditor } from "./_helpers/editor"; import { alignCenter, justify, alignLeft, alignRight } from "./_helpers/user_actions"; describe("left", () => { test("should align left", async () => { await testEditor({ contentBefore: "

ab

c[]d

", stepFunction: alignLeft, contentAfter: "

ab

c[]d

", }); }); test("should not align left a non-editable node", async () => { await testEditor({ contentBefore: '

ab

c[]d

', contentBeforeEdit: '

ab

c[]d

', stepFunction: alignLeft, contentAfterEdit: '

ab

c[]d

', contentAfter: '

ab

c[]d

', }); }); test("should align several paragraphs left", async () => { await testEditor({ contentBefore: "

a[b

c]d

", stepFunction: alignLeft, contentAfter: "

a[b

c]d

", }); }); test("should left align a node within a right-aligned node", async () => { await testEditor({ contentBefore: '

ab

c[d]e

', stepFunction: alignLeft, contentAfter: '

ab

c[d]e

', }); }); test("should left align a node within a right-aligned node and a paragraph", async () => { await testEditor({ contentBefore: '

ab

c[d

e]f

', stepFunction: alignLeft, contentAfter: '

ab

c[d

e]f

', }); }); test("should left align a node within a right-aligned node and a paragraph, with a center-aligned common ancestor", async () => { await testEditor({ contentBefore: '

ab

c[d

e]f

', stepFunction: alignLeft, contentAfter: '

ab

c[d

e]f

', }); }); test("should left align a node within a right-aligned node and a paragraph, with a left-aligned common ancestor", async () => { await testEditor({ contentBefore: '

ab

c[d

e]f

', stepFunction: alignLeft, contentAfter: '

ab

c[d

e]f

', }); }); test("should not left align a node that is already within a left-aligned node", async () => { await testEditor({ contentBefore: '

ab

c[d]e

', stepFunction: alignLeft, contentAfter: '

ab

c[d]e

', }); }); test("should left align a container within an editable that is center-aligned", async () => { await testEditor({ contentBefore: '

a[]b

', stepFunction: alignLeft, contentAfter: '

a[]b

', }); }); }); describe("center", () => { test("should align center", async () => { await testEditor({ contentBefore: "

ab

c[]d

", stepFunction: alignCenter, contentAfter: '

ab

c[]d

', }); }); test("should align several paragraphs center", async () => { await testEditor({ contentBefore: "

a[b

c]d

", stepFunction: alignCenter, contentAfter: '

a[b

c]d

', }); }); test("should center align a node within a right-aligned node", async () => { await testEditor({ contentBefore: '

ab

c[d]e

', stepFunction: alignCenter, contentAfter: '

ab

c[d]e

', }); }); test("should center align a node within a right-aligned node and a paragraph", async () => { await testEditor({ contentBefore: '

ab

c[d

e]f

', stepFunction: alignCenter, contentAfter: '

ab

c[d

e]f

', }); }); test("should center align a node within a right-aligned node and a paragraph, with a left-aligned common ancestor", async () => { await testEditor({ contentBefore: '

ab

c[d

e]f

', stepFunction: alignCenter, contentAfter: '

ab

c[d

e]f

', }); }); test("should center align a node within a right-aligned node and a paragraph, with a center-aligned common ancestor", async () => { await testEditor({ contentBefore: '

ab

c[d

e]f

', stepFunction: alignCenter, contentAfter: '

ab

c[d

e]f

', }); }); test("should not center align a node that is already within a center-aligned node", async () => { await testEditor({ contentBefore: '

ab

c[d]e

', stepFunction: alignCenter, contentAfter: '

ab

c[d]e

', }); }); test("should center align a left-aligned container within an editable that is center-aligned", async () => { await testEditor({ contentBefore: '

a[]b

', stepFunction: alignCenter, contentAfter: '

a[]b

', }); }); }); describe("right", () => { test("should align right", async () => { await testEditor({ contentBefore: "

ab

c[]d

", stepFunction: alignRight, contentAfter: '

ab

c[]d

', }); }); test("should align several paragraphs right", async () => { await testEditor({ contentBefore: "

a[b

c]d

", stepFunction: alignRight, contentAfter: '

a[b

c]d

', }); }); test("should right align a node within a center-aligned node", async () => { await testEditor({ contentBefore: '

ab

c[d]e

', stepFunction: alignRight, contentAfter: '

ab

c[d]e

', }); }); test("should right align a node within a center-aligned node and a paragraph", async () => { await testEditor({ contentBefore: '

ab

c[d

e]f

', stepFunction: alignRight, contentAfter: '

ab

c[d

e]f

', }); }); test("should right align a node within a center-aligned node and a paragraph, with a justify-aligned common ancestor", async () => { await testEditor({ contentBefore: '

ab

c[d

e]f

', stepFunction: alignRight, contentAfter: '

ab

c[d

e]f

', }); }); test("should right align a node within a center-aligned node and a paragraph, with a right-aligned common ancestor", async () => { await testEditor({ contentBefore: '

ab

c[d

e]f

', stepFunction: alignRight, contentAfter: '

ab

c[d

e]f

', }); }); test("should not right align a node that is already within a right-aligned node", async () => { await testEditor({ contentBefore: '

ab

c[d]e

', stepFunction: alignRight, contentAfter: '

ab

c[d]e

', }); }); test("should right align a container within an editable that is center-aligned", async () => { await testEditor({ contentBefore: '

a[]b

', stepFunction: alignRight, contentAfter: '

a[]b

', }); }); }); describe("justify", () => { test("should align justify", async () => { await testEditor({ contentBefore: "

ab

c[]d

", stepFunction: justify, contentAfter: '

ab

c[]d

', }); }); test("should align several paragraphs justify", async () => { await testEditor({ contentBefore: "

a[b

c]d

", stepFunction: justify, contentAfter: '

a[b

c]d

', }); }); test("should justify align a node within a right-aligned node", async () => { await testEditor({ contentBefore: '

ab

c[d]e

', stepFunction: justify, contentAfter: '

ab

c[d]e

', }); }); test("should justify align a node within a right-aligned node and a paragraph", async () => { await testEditor({ contentBefore: '

ab

c[d

e]f

', stepFunction: justify, contentAfter: '

ab

c[d

e]f

', }); }); test("should justify align a node within a right-aligned node and a paragraph, with a center-aligned common ancestor", async () => { await testEditor({ contentBefore: '

ab

c[d

e]f

', stepFunction: justify, contentAfter: '

ab

c[d

e]f

', }); }); test("should justify align a node within a right-aligned node and a paragraph, with a justify-aligned common ancestor", async () => { await testEditor({ contentBefore: '

ab

c[d

e]f

', stepFunction: justify, contentAfter: '

ab

c[d

e]f

', }); }); test("should not justify align a node that is already within a justify-aligned node", async () => { await testEditor({ contentBefore: '

ab

c[d]e

', stepFunction: justify, contentAfter: '

ab

c[d]e

', }); }); test("should justify align a container within an editable that is center-aligned", async () => { await testEditor({ contentBefore: '

a[]b

', stepFunction: justify, contentAfter: '

a[]b

', }); }); });