iterative/vscode-dvc

View on GitHub
webview/src/test/selection.ts

Summary

Maintainability
A
0 mins
Test Coverage
export const createWindowTextSelection = (
  nodeValue: string | null,
  offset = 0
) => {
  window.getSelection = () => {
    return {
      anchorOffset: 1,
      focusNode: nodeValue ? ({ nodeValue } as Node) : null,
      focusOffset: 1 + offset
    } as Selection
  }
}

export const clearSelection = () => createWindowTextSelection(null)