MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / testSubstituteConfirm

Function testSubstituteConfirm

lib/web/CodeMirror/test/vim_test.js:4344–4387  ·  view source on GitHub ↗
(name, command, initialValue, expectedValue, keys, finalPos)

Source from the content-addressed store, hash-verified

4342 expectedValue: 'xaa\nbxa\ncxa',
4343 expr: '%s/a/x/'});
4344function testSubstituteConfirm(name, command, initialValue, expectedValue, keys, finalPos) {
4345 testVim(name, function(cm, vim, helpers) {
4346 var savedOpenDialog = cm.openDialog;
4347 var savedKeyName = CodeMirror.keyName;
4348 var onKeyDown;
4349 var recordedCallback;
4350 var closed = true; // Start out closed, set false on second openDialog.
4351 function close() {
4352 closed = true;
4353 }
4354 // First openDialog should save callback.
4355 cm.openDialog = function(template, callback, options) {
4356 recordedCallback = callback;
4357 }
4358 // Do first openDialog.
4359 helpers.doKeys(':');
4360 // Second openDialog should save keyDown handler.
4361 cm.openDialog = function(template, callback, options) {
4362 onKeyDown = options.onKeyDown;
4363 closed = false;
4364 };
4365 // Return the command to Vim and trigger second openDialog.
4366 recordedCallback(command);
4367 // The event should really use keyCode, but here just mock it out and use
4368 // key and replace keyName to just return key.
4369 CodeMirror.keyName = function (e) { return e.key; }
4370 keys = keys.toUpperCase();
4371 for (var i = 0; i < keys.length; i++) {
4372 is(!closed);
4373 onKeyDown({ key: keys.charAt(i) }, '', close);
4374 }
4375 try {
4376 eq(expectedValue, cm.getValue());
4377 helpers.assertCursorAt(finalPos);
4378 is(closed);
4379 } catch(e) {
4380 throw e
4381 } finally {
4382 // Restore overridden functions.
4383 CodeMirror.keyName = savedKeyName;
4384 cm.openDialog = savedOpenDialog;
4385 }
4386 }, { value: initialValue });
4387}
4388testSubstituteConfirm('ex_substitute_confirm_emptydoc',
4389 '%s/x/b/c', '', '', '', makeCursor(0, 0));
4390testSubstituteConfirm('ex_substitute_confirm_nomatch',

Callers 1

vim_test.jsFile · 0.85

Calls 5

testVimFunction · 0.85
eqFunction · 0.85
isFunction · 0.70
onKeyDownFunction · 0.50
getValueMethod · 0.45

Tested by

no test coverage detected