github.com/hernad/nomad@v1.6.112/ui/tests/helpers/codemirror.js (about)

     1  /**
     2   * Copyright (c) HashiCorp, Inc.
     3   * SPDX-License-Identifier: MPL-2.0
     4   */
     5  
     6  export function getCodeMirrorInstance() {
     7    return function () {
     8      return document.querySelector('.CodeMirror').CodeMirror;
     9    };
    10  }
    11  
    12  export default function setupCodeMirror(hooks) {
    13    hooks.beforeEach(function () {
    14      this.getCodeMirrorInstance = getCodeMirrorInstance(this.owner);
    15  
    16      // Expose to window for access from page objects
    17      window.getCodeMirrorInstance = this.getCodeMirrorInstance;
    18    });
    19  
    20    hooks.afterEach(function () {
    21      delete window.getCodeMirrorInstance;
    22      delete this.getCodeMirrorInstance;
    23    });
    24  }