(name, run, opts, expectedFail)
| 256 | } |
| 257 | |
| 258 | function testVim(name, run, opts, expectedFail) { |
| 259 | var vimOpts = { |
| 260 | lineNumbers: true, |
| 261 | vimMode: true, |
| 262 | showCursorWhenSelecting: true, |
| 263 | value: code |
| 264 | }; |
| 265 | for (var prop in opts) { |
| 266 | if (opts.hasOwnProperty(prop)) { |
| 267 | vimOpts[prop] = opts[prop]; |
| 268 | } |
| 269 | } |
| 270 | return test('vim_' + name, async function(done) { |
| 271 | var place = document.createElement("testground"); //ace_patch |
| 272 | place.style.visibility = "visible"; |
| 273 | var cm = CodeMirror(place, vimOpts); |
| 274 | var vim = CodeMirror.Vim.maybeInitVimState_(cm); |
| 275 | CodeMirror.Vim.mapclear(); |
| 276 | |
| 277 | cm.focus(); |
| 278 | // workaround for cm5 slow polling in blurred window |
| 279 | Object.defineProperty(cm.state, "focused", { |
| 280 | set: function(e) {}, |
| 281 | get: function() { |
| 282 | return document.activeElement == cm.getInputField(); |
| 283 | } |
| 284 | }); |
| 285 | |
| 286 | var helpers = { |
| 287 | doKeys: function() { |
| 288 | var args = arguments[0] |
| 289 | if (!Array.isArray(args)) { args = arguments; } |
| 290 | for (var i = 0; i < args.length; i++) { |
| 291 | var key = args[i]; |
| 292 | if (key.length > 1 && key[0] == "<" && key.slice(-1) == ">") { |
| 293 | key = vimKeyToKeyName(key.slice(1, -1)); |
| 294 | } |
| 295 | typeKey(key); |
| 296 | } |
| 297 | }, |
| 298 | doEx: function(command) { |
| 299 | helpers.doKeys(':', command, '\n'); |
| 300 | }, |
| 301 | assertCursorAt: function(line, ch) { |
| 302 | var pos; |
| 303 | if (ch == null && typeof line.line == 'number') { |
| 304 | pos = line; |
| 305 | } else { |
| 306 | pos = makeCursor(line, ch); |
| 307 | } |
| 308 | eqCursorPos(cm.getCursor(), pos); |
| 309 | }, |
| 310 | getRegisterController: function() { |
| 311 | return CodeMirror.Vim.getRegisterController(); |
| 312 | }, |
| 313 | getNotificationText: function() { |
| 314 | var container = cm.getWrapperElement().querySelector(".cm-vim-message"); |
| 315 | return container && container.textContent; |
no test coverage detected
searching dependent graphs…