github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/ui/tests/pages/helpers/codemirror.js (about)

     1  // Like fillable, but for the CodeMirror editor
     2  //
     3  // Usage: fillIn: codeFillable('[data-test-editor]')
     4  //        Page.fillIn(code);
     5  export function codeFillable(selector) {
     6    return {
     7      isDescriptor: true,
     8  
     9      get() {
    10        return function(code) {
    11          const cm = getCodeMirrorInstance(selector);
    12          cm.setValue(code);
    13          return this;
    14        };
    15      },
    16    };
    17  }
    18  
    19  // Like text, but for the CodeMirror editor
    20  //
    21  // Usage: content: code('[data-test-editor]')
    22  //        Page.code(); // some = [ 'string', 'of', 'code' ]
    23  export function code(selector) {
    24    return {
    25      isDescriptor: true,
    26  
    27      get() {
    28        const cm = getCodeMirrorInstance(selector);
    29        return cm.getValue();
    30      },
    31    };
    32  }