Skip to content
Snippets Groups Projects
Unverified Commit 46e7b979 authored by Tom Robinson's avatar Tom Robinson
Browse files

Add a test for @salsakran

parent 19956586
No related branches found
No related tags found
No related merge requests found
import { getSelectionPosition, setSelectionPosition } from "metabase/lib/dom"
describe("getSelectionPosition/setSelectionPosition", () => {
let container;
beforeEach(() => {
container = document.createElement("div");
document.body.appendChild(container);
})
afterEach(() => {
document.body.removeChild(container);
})
it("should get/set selection on input correctly", () => {
let input = document.createElement("input");
container.appendChild(input);
input.value = "hello world";
setSelectionPosition(input, [3, 6]);
const position = getSelectionPosition(input);
expect(position).toEqual([3, 6]);
});
it("should get/set selection on contenteditable correctly", () => {
let contenteditable = document.createElement("div");
container.appendChild(contenteditable);
contenteditable.textContent = "<div>hello world</div>"
setSelectionPosition(contenteditable, [3, 6]);
const position = getSelectionPosition(contenteditable);
expect(position).toEqual([3, 6]);
});
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment