2023-04-10 15:36:59 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*/
|
|
|
|
|
2022-07-04 20:47:58 +00:00
|
|
|
export function getCodeMirrorInstance() {
|
|
|
|
return function () {
|
|
|
|
return document.querySelector('.CodeMirror').CodeMirror;
|
2018-08-23 00:34:25 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-03-14 06:44:17 +00:00
|
|
|
export default function setupCodeMirror(hooks) {
|
2021-12-28 14:45:20 +00:00
|
|
|
hooks.beforeEach(function () {
|
2019-03-14 06:44:17 +00:00
|
|
|
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 () {
|
2019-03-14 06:44:17 +00:00
|
|
|
delete window.getCodeMirrorInstance;
|
|
|
|
delete this.getCodeMirrorInstance;
|
2018-08-16 17:56:37 +00:00
|
|
|
});
|
|
|
|
}
|