當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。