import { describe, test } from "@odoo/hoot"; import { deleteBackward } from "../_helpers/user_actions"; import { testEditor } from "../_helpers/editor"; describe("delete selection involving links", () => { test("should remove link", async () => { await testEditor({ contentBefore: '
[abcd]ef
', contentBeforeEdit: '\ufeff\ufeff[abc\ufeff\ufeffd]ef
', stepFunction: deleteBackward, contentAfterEdit: "[]ef
", contentAfter: "[]ef
", }); }); test("should remove link (2)", async () => { await testEditor({ contentBefore: 'ab[cdef]
', contentBeforeEdit: 'ab[c\ufeff\ufeffdef]\ufeff\ufeff
', stepFunction: deleteBackward, contentAfterEdit: "ab[]
", contentAfter: "ab[]
", }); }); test("should not remove link (only after clean)", async () => { await testEditor({ contentBefore: '[abc]def
', contentBeforeEdit: '\ufeff\ufeff[abc]\ufeff\ufeffdef
', stepFunction: deleteBackward, contentAfterEdit: '\ufeff\ufeff[]\ufeff\ufeffdef
', contentAfter: "[]def
", }); }); }); describe("empty list items, starting and ending with links", () => { // Since we introduce \ufeff characters in and around links, we // can enter situations where the links aren't technically fully // selected but should be treated as if they were. These tests // are there to ensure that is the case. They represent four // variations of the same situation, and have the same expected // result. const tests = [ // (1) [.........] '', '', '', '', '', // (2) [.........] '', '', '', '', '', // (3) [.........] '', '', '', '', '', // (4) [.........] '', '', '', '', '', ]; let testIndex = 1; for (const contentBefore of tests) { test(`should empty list items, starting and ending with links (${testIndex})`, async () => { await testEditor({ contentBefore, stepFunction: deleteBackward, contentAfterEdit: '