本文整理匯總了TypeScript中vs/editor/test/browser/testCodeEditor.withTestCodeEditor函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript withTestCodeEditor函數的具體用法?TypeScript withTestCodeEditor怎麽用?TypeScript withTestCodeEditor使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了withTestCodeEditor函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test
test('toggle case', function () {
withTestCodeEditor(
[
'hello world',
'öçşğü'
], {}, (editor, cursor) => {
let model = editor.getModel();
let uppercaseAction = new UpperCaseAction();
let lowercaseAction = new LowerCaseAction();
editor.setSelection(new Selection(1, 1, 1, 12));
uppercaseAction.run(null, editor);
assert.equal(model.getLineContent(1), 'HELLO WORLD', '001');
assert.deepEqual(editor.getSelection().toString(), new Selection(1, 1, 1, 12).toString(), '002');
editor.setSelection(new Selection(1, 1, 1, 12));
lowercaseAction.run(null, editor);
assert.equal(model.getLineContent(1), 'hello world', '003');
assert.deepEqual(editor.getSelection().toString(), new Selection(1, 1, 1, 12).toString(), '004');
editor.setSelection(new Selection(1, 3, 1, 3));
uppercaseAction.run(null, editor);
assert.equal(model.getLineContent(1), 'HELLO world', '005');
assert.deepEqual(editor.getSelection().toString(), new Selection(1, 3, 1, 3).toString(), '006');
editor.setSelection(new Selection(1, 4, 1, 4));
lowercaseAction.run(null, editor);
assert.equal(model.getLineContent(1), 'hello world', '007');
assert.deepEqual(editor.getSelection().toString(), new Selection(1, 4, 1, 4).toString(), '008');
editor.setSelection(new Selection(2, 1, 2, 6));
uppercaseAction.run(null, editor);
assert.equal(model.getLineContent(2), 'ÖÇŞĞÜ', '009');
assert.deepEqual(editor.getSelection().toString(), new Selection(2, 1, 2, 6).toString(), '010');
editor.setSelection(new Selection(2, 1, 2, 6));
lowercaseAction.run(null, editor);
assert.equal(model.getLineContent(2), 'öçşğü', '011');
assert.deepEqual(editor.getSelection().toString(), new Selection(2, 1, 2, 6).toString(), '012');
}
);
withTestCodeEditor(
[
'',
' '
], {}, (editor, cursor) => {
let model = editor.getModel();
let uppercaseAction = new UpperCaseAction();
let lowercaseAction = new LowerCaseAction();
editor.setSelection(new Selection(1, 1, 1, 1));
uppercaseAction.run(null, editor);
assert.equal(model.getLineContent(1), '', '013');
assert.deepEqual(editor.getSelection().toString(), new Selection(1, 1, 1, 1).toString(), '014');
editor.setSelection(new Selection(1, 1, 1, 1));
lowercaseAction.run(null, editor);
assert.equal(model.getLineContent(1), '', '015');
assert.deepEqual(editor.getSelection().toString(), new Selection(1, 1, 1, 1).toString(), '016');
editor.setSelection(new Selection(2, 2, 2, 2));
uppercaseAction.run(null, editor);
assert.equal(model.getLineContent(2), ' ', '017');
assert.deepEqual(editor.getSelection().toString(), new Selection(2, 2, 2, 2).toString(), '018');
editor.setSelection(new Selection(2, 2, 2, 2));
lowercaseAction.run(null, editor);
assert.equal(model.getLineContent(2), ' ', '019');
assert.deepEqual(editor.getSelection().toString(), new Selection(2, 2, 2, 2).toString(), '020');
}
);
});
示例2: test
test('transpose', function () {
withTestCodeEditor(
[
'hello world',
'',
'',
' ',
], {}, (editor, cursor) => {
let model = editor.getModel();
let transposeAction = new TransposeAction();
editor.setSelection(new Selection(1, 1, 1, 1));
transposeAction.run(null, editor);
assert.equal(model.getLineContent(1), 'hello world', '001');
assert.deepEqual(editor.getSelection().toString(), new Selection(1, 2, 1, 2).toString(), '002');
editor.setSelection(new Selection(1, 6, 1, 6));
transposeAction.run(null, editor);
assert.equal(model.getLineContent(1), 'hell oworld', '003');
assert.deepEqual(editor.getSelection().toString(), new Selection(1, 7, 1, 7).toString(), '004');
editor.setSelection(new Selection(1, 12, 1, 12));
transposeAction.run(null, editor);
assert.equal(model.getLineContent(1), 'hell oworl', '005');
assert.deepEqual(editor.getSelection().toString(), new Selection(2, 2, 2, 2).toString(), '006');
editor.setSelection(new Selection(3, 1, 3, 1));
transposeAction.run(null, editor);
assert.equal(model.getLineContent(3), '', '007');
assert.deepEqual(editor.getSelection().toString(), new Selection(4, 1, 4, 1).toString(), '008');
editor.setSelection(new Selection(4, 2, 4, 2));
transposeAction.run(null, editor);
assert.equal(model.getLineContent(4), ' ', '009');
assert.deepEqual(editor.getSelection().toString(), new Selection(4, 3, 4, 3).toString(), '010');
}
);
// fix #16633
withTestCodeEditor(
[
'',
'',
'hello',
'world',
'',
'hello world',
'',
'hello world'
], {}, (editor, cursor) => {
let model = editor.getModel();
let transposeAction = new TransposeAction();
editor.setSelection(new Selection(1, 1, 1, 1));
transposeAction.run(null, editor);
assert.equal(model.getLineContent(2), '', '011');
assert.deepEqual(editor.getSelection().toString(), new Selection(2, 1, 2, 1).toString(), '012');
editor.setSelection(new Selection(3, 6, 3, 6));
transposeAction.run(null, editor);
assert.equal(model.getLineContent(4), 'oworld', '013');
assert.deepEqual(editor.getSelection().toString(), new Selection(4, 2, 4, 2).toString(), '014');
editor.setSelection(new Selection(6, 12, 6, 12));
transposeAction.run(null, editor);
assert.equal(model.getLineContent(7), 'd', '015');
assert.deepEqual(editor.getSelection().toString(), new Selection(7, 2, 7, 2).toString(), '016');
editor.setSelection(new Selection(8, 12, 8, 12));
transposeAction.run(null, editor);
assert.equal(model.getLineContent(8), 'hello world', '019');
assert.deepEqual(editor.getSelection().toString(), new Selection(8, 12, 8, 12).toString(), '020');
}
);
});
示例3: test
test('should keep deleting lines in multi cursor mode', function () {
withTestCodeEditor(
[
'hi my name is Carlos Matos',
'BCC',
'waso waso waso',
'my wife doesnt believe in me',
'nonononono',
'bitconneeeect'
], {}, (editor) => {
let model = editor.getModel()!;
let deleteAllLeftAction = new DeleteAllLeftAction();
const beforeSecondWasoSelection = new Selection(3, 5, 3, 5);
const endOfBCCSelection = new Selection(2, 4, 2, 4);
const endOfNonono = new Selection(5, 11, 5, 11);
editor.setSelections([beforeSecondWasoSelection, endOfBCCSelection, endOfNonono]);
let selections;
deleteAllLeftAction.run(null!, editor);
selections = editor.getSelections();
assert.equal(model.getLineContent(2), '');
assert.equal(model.getLineContent(3), ' waso waso');
assert.equal(model.getLineContent(5), '');
assert.deepEqual([
selections[0].startLineNumber,
selections[0].startColumn,
selections[0].endLineNumber,
selections[0].endColumn
], [3, 1, 3, 1]);
assert.deepEqual([
selections[1].startLineNumber,
selections[1].startColumn,
selections[1].endLineNumber,
selections[1].endColumn
], [2, 1, 2, 1]);
assert.deepEqual([
selections[2].startLineNumber,
selections[2].startColumn,
selections[2].endLineNumber,
selections[2].endColumn
], [5, 1, 5, 1]);
deleteAllLeftAction.run(null!, editor);
selections = editor.getSelections();
assert.equal(model.getLineContent(1), 'hi my name is Carlos Matos waso waso');
assert.equal(selections.length, 2);
assert.deepEqual([
selections[0].startLineNumber,
selections[0].startColumn,
selections[0].endLineNumber,
selections[0].endColumn
], [1, 27, 1, 27]);
assert.deepEqual([
selections[1].startLineNumber,
selections[1].startColumn,
selections[1].endLineNumber,
selections[1].endColumn
], [2, 29, 2, 29]);
});
});