import { test } from "@odoo/hoot";
import { press } from "@odoo/hoot-dom";
import { testEditor } from "../_helpers/editor";
import { unformat } from "../_helpers/format";
const ctrlShiftBackspace = () => press(["Ctrl", "Shift", "Backspace"]);
test("should do nothing on ctrl+shift+backspace", async () => {
await testEditor({
contentBefore: "
[]
",
stepFunction: ctrlShiftBackspace,
contentAfter: "[]
",
});
});
test("should delete to start of paragraph with ctrl+shift+backspace", async () => {
await testEditor({
contentBefore: "abc def[]
",
stepFunction: ctrlShiftBackspace,
contentAfter: "[]
",
});
});
test("should delete to start of paragraph with ctrl+shift+backspace (2)", async () => {
await testEditor({
contentBefore: "abc def[] ghi
",
stepFunction: ctrlShiftBackspace,
contentAfter: "[] ghi
",
});
});
test.tags("focus required");
test("should delete to start of paragraph with ctrl+shift+backspace (3)", async () => {
await testEditor({
contentBefore: "first paragraph
abc def[]
",
stepFunction: ctrlShiftBackspace,
contentAfter: "first paragraph
[]
",
});
});
test("should delete text between line-break and cursor", async () => {
await testEditor({
contentBefore: "text
abc def []ghi
",
stepFunction: ctrlShiftBackspace,
contentAfter: "text
[]ghi
",
});
});
test("should delete text between line-break and cursor (2)", async () => {
await testEditor({
contentBefore: "text
abc def ghi[]
",
stepFunction: ctrlShiftBackspace,
contentAfter: "text
[]
",
});
});
test("should delete text between cursor and previous line-break", async () => {
await testEditor({
contentBefore: "text
more text
abc def []ghi
",
stepFunction: ctrlShiftBackspace,
contentAfter: "text
more text
[]ghi
",
});
});
test("should not remove an unremovable element on CTRL+SHIFT+BACKSPACE", async () => {
await testEditor({
contentBefore: unformat(`
abc
[]
`),
stepFunction: ctrlShiftBackspace,
contentAfter: unformat(`
abc
[]
`),
});
});
test("should not merge an unbreakable element on CTRL+SHIFT+BACKSPACE", async () => {
await testEditor({
contentBefore: unformat(`
abc
[]def
`),
stepFunction: ctrlShiftBackspace,
contentAfter: unformat(`
abc
[]def
`),
});
});
test("should not merge an unbreakable element on CTRL+SHIFT+BACKSPACE (2)", async () => {
await testEditor({
contentBefore: unformat(`
abc
[]def
`),
stepFunction: ctrlShiftBackspace,
contentAfter: unformat(`
abc
[]def
`),
});
});