All files / src/Simulate Actions.ts

22.22% Statements 2/9
100% Branches 0/0
0% Functions 0/3
22.22% Lines 2/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 222x   2x                                      
import { Defer } from "coveo-search-ui";
 
export function keyUp(
  element: HTMLElement,
  key: number,
  shiftKey?: boolean
): void {
  const event = new KeyboardEvent("keyup", { shiftKey: shiftKey });
  Object.defineProperty(event, "keyCode", {
    get: () => {
      return key;
    }
  });
  Object.defineProperty(event, "which", {
    get: () => {
      return key;
    }
  });
  element.dispatchEvent(event);
  Defer.flush();
}