open-vault/ui/tests/helpers/codemirror.js
Matthew Irish 5e5b6e9f7a
UI json edit test (#5705)
* add new codemirror helpers

* adding json helpers to the secret pages

* mark the edit button / link as the edit element instead of the json toggle

* add acceptance tests for JSON editing
2018-11-09 14:00:53 -06:00

16 lines
440 B
JavaScript

const invariant = (truthy, error) => {
if (!truthy) throw new Error(error);
};
export default function(context, selector) {
let cmService = context.owner.lookup('service:code-mirror');
let element = document.querySelector(selector);
invariant(element, `Selector ${selector} matched no elements`);
let cm = cmService.instanceFor(element.id);
invariant(cm, `No registered CodeMirror instance for ${selector}`);
return cm;
}