当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript mockCodeEditor.withMockCodeEditor函数代码示例

本文整理汇总了TypeScript中vs/editor/test/common/mocks/mockCodeEditor.withMockCodeEditor函数的典型用法代码示例。如果您正苦于以下问题:TypeScript withMockCodeEditor函数的具体用法?TypeScript withMockCodeEditor怎么用?TypeScript withMockCodeEditor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了withMockCodeEditor函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: test

		test('should be noop on empty', () => {
			withMockCodeEditor([''], {}, (editor, cursor) => {
				const model = editor.getModel();
				const action = new DeleteAllRightAction();

				action.run(null, editor);
				assert.deepEqual(model.getLinesContent(), ['']);
				assert.deepEqual(editor.getSelections(), [new Selection(1, 1, 1, 1)]);

				editor.setSelection(new Selection(1, 1, 1, 1));
				action.run(null, editor);
				assert.deepEqual(model.getLinesContent(), ['']);
				assert.deepEqual(editor.getSelections(), [new Selection(1, 1, 1, 1)]);

				editor.setSelections([new Selection(1, 1, 1, 1), new Selection(1, 1, 1, 1), new Selection(1, 1, 1, 1)]);
				action.run(null, editor);
				assert.deepEqual(model.getLinesContent(), ['']);
				assert.deepEqual(editor.getSelections(), [new Selection(1, 1, 1, 1)]);
			});
		});
开发者ID:gokulakrishna9,项目名称:vscode,代码行数:20,代码来源:linesOperations.test.ts

示例2: test

	test('issue #832: deleteWordLeft', () => {
		withMockCodeEditor([
			'   /* Just some text a+= 3 +5 */  '
		], {}, (editor, _) => {
			const model = editor.getModel();
			editor.setPosition(new Position(1, 37));
			deleteWordLeft(editor); assert.equal(model.getLineContent(1), '   /* Just some text a+= 3 +5 */', '001');
			deleteWordLeft(editor); assert.equal(model.getLineContent(1), '   /* Just some text a+= 3 +5 ', '002');
			deleteWordLeft(editor); assert.equal(model.getLineContent(1), '   /* Just some text a+= 3 +', '003');
			deleteWordLeft(editor); assert.equal(model.getLineContent(1), '   /* Just some text a+= 3 ', '004');
			deleteWordLeft(editor); assert.equal(model.getLineContent(1), '   /* Just some text a+= ', '005');
			deleteWordLeft(editor); assert.equal(model.getLineContent(1), '   /* Just some text a', '006');
			deleteWordLeft(editor); assert.equal(model.getLineContent(1), '   /* Just some text ', '007');
			deleteWordLeft(editor); assert.equal(model.getLineContent(1), '   /* Just some ', '008');
			deleteWordLeft(editor); assert.equal(model.getLineContent(1), '   /* Just ', '009');
			deleteWordLeft(editor); assert.equal(model.getLineContent(1), '   /* ', '010');
			deleteWordLeft(editor); assert.equal(model.getLineContent(1), '   ', '011');
			deleteWordLeft(editor); assert.equal(model.getLineContent(1), '', '012');
		});
	});
开发者ID:hungys,项目名称:vscode,代码行数:20,代码来源:wordOperations.test.ts

示例3: test

	test('issue #832: deleteWordRight', () => {
		withMockCodeEditor([
			'   /* Just some text a+= 3 +5-3 */  '
		], {}, (editor, _) => {
			const model = editor.getModel();
			editor.setPosition(new Position(1, 1));
			deleteWordRight(editor); assert.equal(model.getLineContent(1), '/* Just some text a+= 3 +5-3 */  ', '001');
			deleteWordRight(editor); assert.equal(model.getLineContent(1), ' Just some text a+= 3 +5-3 */  ', '002');
			deleteWordRight(editor); assert.equal(model.getLineContent(1), ' some text a+= 3 +5-3 */  ', '003');
			deleteWordRight(editor); assert.equal(model.getLineContent(1), ' text a+= 3 +5-3 */  ', '004');
			deleteWordRight(editor); assert.equal(model.getLineContent(1), ' a+= 3 +5-3 */  ', '005');
			deleteWordRight(editor); assert.equal(model.getLineContent(1), '+= 3 +5-3 */  ', '006');
			deleteWordRight(editor); assert.equal(model.getLineContent(1), ' 3 +5-3 */  ', '007');
			deleteWordRight(editor); assert.equal(model.getLineContent(1), ' +5-3 */  ', '008');
			deleteWordRight(editor); assert.equal(model.getLineContent(1), '5-3 */  ', '009');
			deleteWordRight(editor); assert.equal(model.getLineContent(1), '-3 */  ', '010');
			deleteWordRight(editor); assert.equal(model.getLineContent(1), '3 */  ', '011');
			deleteWordRight(editor); assert.equal(model.getLineContent(1), ' */  ', '012');
			deleteWordRight(editor); assert.equal(model.getLineContent(1), '  ', '013');
		});
	});
开发者ID:jhasse,项目名称:vscode,代码行数:21,代码来源:wordOperations.test.ts

示例4: test

	test('issue #3090: F3 does not loop with two matches on a single line', () => {
		withMockCodeEditor([
			'import nls = require(\'vs/nls\');'
		], {}, (editor, cursor) => {

			let findController = editor.registerAndInstantiateContribution<TestFindController>(TestFindController);
			let nextMatchFindAction = new NextMatchFindAction();

			editor.setPosition({
				lineNumber: 1,
				column: 9
			});

			nextMatchFindAction.run(null, editor);
			assert.deepEqual(fromRange(editor.getSelection()), [1, 26, 1, 29]);

			nextMatchFindAction.run(null, editor);
			assert.deepEqual(fromRange(editor.getSelection()), [1, 8, 1, 11]);

			findController.dispose();
		});
	});
开发者ID:BlackstarSoon,项目名称:vscode,代码行数:22,代码来源:findController.test.ts

示例5: test

	test('search string at position', () => {
		withMockCodeEditor([
			'ABC DEF',
			'0123 456'
		], {}, (editor, cursor) => {

			// The cursor is at the very top, of the file, at the first ABC
			let searchStringAtTop = getSelectionSearchString(editor);
			assert.equal(searchStringAtTop, 'ABC');

			// Move cursor to the end of ABC
			editor.setPosition(new Position(1, 3));
			let searchStringAfterABC = getSelectionSearchString(editor);
			assert.equal(searchStringAfterABC, 'ABC');

			// Move cursor to DEF
			editor.setPosition(new Position(1, 5));
			let searchStringInsideDEF = getSelectionSearchString(editor);
			assert.equal(searchStringInsideDEF, 'DEF');

		});
	});
开发者ID:Chan-PH,项目名称:vscode,代码行数:22,代码来源:find.test.ts

示例6: testCommand

export function testCommand(
	lines: string[],
	languageIdentifier: LanguageIdentifier,
	selection: Selection,
	commandFactory: (selection: Selection) => editorCommon.ICommand,
	expectedLines: string[],
	expectedSelection: Selection
): void {
	let model = Model.createFromString(lines.join('\n'), undefined, languageIdentifier);
	withMockCodeEditor(null, { model: model }, (editor, cursor) => {

		cursor.setSelections('tests', [selection]);

		cursor.trigger('tests', editorCommon.Handler.ExecuteCommand, commandFactory(cursor.getSelection()));

		assert.deepEqual(model.getLinesContent(), expectedLines);

		let actualSelection = cursor.getSelection();
		assert.deepEqual(actualSelection.toString(), expectedSelection.toString());

	});
	model.dispose();
}
开发者ID:jhasse,项目名称:vscode,代码行数:23,代码来源:commandTestUtils.ts


注:本文中的vs/editor/test/common/mocks/mockCodeEditor.withMockCodeEditor函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。