open-nomad/ui/tests/helpers/codemirror.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
606 B
JavaScript
Raw Normal View History

/**
* 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) {
2021-12-28 14:45:20 +00:00
hooks.beforeEach(function () {
this.getCodeMirrorInstance = getCodeMirrorInstance(this.owner);
// Expose to window for access from page objects
window.getCodeMirrorInstance = this.getCodeMirrorInstance;
});
2021-12-28 14:45:20 +00:00
hooks.afterEach(function () {
delete window.getCodeMirrorInstance;
delete this.getCodeMirrorInstance;
});
}