import { describe, test } from "@odoo/hoot";
import { press } from "@odoo/hoot-dom";
import { testEditor } from "../_helpers/editor";
import { unformat } from "../_helpers/format";
describe("move selection with tab/shift+tab", () => {
describe("tab", () => {
test("should move cursor to the end of next cell", async () => {
await testEditor({
contentBefore: unformat(`
`),
stepFunction: async () => press("Tab"),
contentAfter: unformat(`
`),
});
});
test.tags("iframe");
test("should move cursor to the end of next cell in an iframe", async () => {
await testEditor({
props: { iframe: true },
contentBefore: unformat(`
`),
stepFunction: async () => press("Tab"),
contentAfter: unformat(`
`),
});
});
test("should move cursor to the end of next cell in the row below", async () => {
await testEditor({
contentBefore: unformat(`
`),
stepFunction: async () => press("Tab"),
contentAfter: unformat(`
`),
});
});
test("move cursor to end of next cell when selection is inside table", async () => {
await testEditor({
contentBefore: unformat(`
`),
stepFunction: async () => press("Tab"),
contentAfter: unformat(`
`),
});
});
});
describe("shift+tab", () => {
test("should move cursor to the end of previous cell", async () => {
await testEditor({
contentBefore: unformat(`
`),
stepFunction: async () => press(["Shift", "Tab"]),
contentAfter: unformat(`
`),
});
});
test("should move cursor to the end of previous cell in the row above", async () => {
await testEditor({
contentBefore: unformat(`
`),
stepFunction: async () => press(["Shift", "Tab"]),
contentAfter: unformat(`
`),
});
});
test("should not cursor if there is no previous cell", async () => {
await testEditor({
contentBefore: unformat(`
`),
stepFunction: async () => press(["Shift", "Tab"]),
contentAfter: unformat(`
`),
});
});
test("move cursor to end of previous cell when selection is inside table", async () => {
await testEditor({
contentBefore: unformat(`
`),
stepFunction: async () => press(["Shift", "Tab"]),
contentAfter: unformat(`
`),
});
});
});
});