open-nomad/ui/tests/helpers/codemirror.js
2023-04-10 15:36:59 +00:00

25 lines
606 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
export function getCodeMirrorInstance() {
return function () {
return document.querySelector('.CodeMirror').CodeMirror;
};
}
export default function setupCodeMirror(hooks) {
hooks.beforeEach(function () {
this.getCodeMirrorInstance = getCodeMirrorInstance(this.owner);
// Expose to window for access from page objects
window.getCodeMirrorInstance = this.getCodeMirrorInstance;
});
hooks.afterEach(function () {
delete window.getCodeMirrorInstance;
delete this.getCodeMirrorInstance;
});
}