mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-24 13:15:40 +00:00
* Feature: adding dynamic variable support (#3609) Co-authored-by: Raghav Sethi <109696225+rsxc@users.noreply.github.com> Co-authored-by: sanjai0py <sanjailucifer666@gmail.com>
46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
const CodeMirror = jest.fn((node, options) => {
|
|
const editor = {
|
|
options,
|
|
_currentValue: '',
|
|
_onKeyUpMockDataHints: null,
|
|
getCursor: jest.fn(() => ({ line: 0, ch: editor._currentValue?.length || 0 })),
|
|
getRange: jest.fn((from, to) => editor._currentValue?.slice(0, to.ch) || ''),
|
|
getValue: jest.fn(() => editor._currentValue),
|
|
setValue: jest.fn(function (val) {
|
|
editor._currentValue = val;
|
|
}),
|
|
getLine: jest.fn(() => editor._currentValue || ''),
|
|
setOption: jest.fn(),
|
|
refresh: jest.fn(),
|
|
off: jest.fn(),
|
|
showHint: jest.fn(),
|
|
on: jest.fn(function (event, handler) {
|
|
if (event === 'keyup') {
|
|
if (handler && handler.name === '_onKeyUpMockDataHints') {
|
|
this._onKeyUpMockDataHints = handler;
|
|
}
|
|
}
|
|
})
|
|
};
|
|
return editor;
|
|
});
|
|
|
|
CodeMirror.commands = {
|
|
autocomplete: jest.fn()
|
|
};
|
|
|
|
CodeMirror.hint = {};
|
|
|
|
CodeMirror.registerHelper = jest.fn((type, name, value) => {
|
|
if (!CodeMirror[type]) {
|
|
CodeMirror[type] = {};
|
|
}
|
|
|
|
CodeMirror[type][name] = value;
|
|
});
|
|
|
|
CodeMirror.fromTextArea = jest.fn();
|
|
CodeMirror.defineMode = jest.fn();
|
|
|
|
module.exports = CodeMirror;
|