當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript TestInstantiationService.createInstance方法代碼示例

本文整理匯總了TypeScript中vs/platform/instantiation/test/common/instantiationServiceMock.TestInstantiationService.createInstance方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript TestInstantiationService.createInstance方法的具體用法?TypeScript TestInstantiationService.createInstance怎麽用?TypeScript TestInstantiationService.createInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vs/platform/instantiation/test/common/instantiationServiceMock.TestInstantiationService的用法示例。


在下文中一共展示了TestInstantiationService.createInstance方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: test

	test('filter by cmd key', () => {
		testObject = instantiationService.createInstance(KeybindingsEditorModel, OperatingSystem.Macintosh);

		const command = 'a' + uuid.generateUuid();
		const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false });
		prepareKeybindingService(expected);

		return testObject.resolve().then(() => {
			const actual = testObject.fetch('cmd').filter(element => element.keybindingItem.command === command);
			assert.equal(1, actual.length);
			assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true });
			assert.deepEqual(actual[0].keybindingMatches.chordPart, {});
		});
	});
開發者ID:elibarzilay,項目名稱:vscode,代碼行數:14,代碼來源:keybindingsEditorModel.test.ts

示例2: setup

	setup(() => {
		storageData = {};
		instantiationService.stub(IStorageService, {
			get: (a, b, c) => a === 'experiments.experiment1' ? JSON.stringify(storageData) : c,
			store: (a, b, c) => {
				if (a === 'experiments.experiment1') {
					storageData = JSON.parse(b);
				}
			}
		});
		instantiationService.stub(INotificationService, new TestNotificationService());
		experimentService = instantiationService.createInstance(TestExperimentService);
		experimentService.onExperimentEnabled = onExperimentEnabledEvent.event;
		instantiationService.stub(IExperimentService, experimentService);
	});
開發者ID:burhandodhy,項目名稱:azuredatastudio,代碼行數:15,代碼來源:experimentalPrompts.test.ts

示例3: setup

		setup(() => {
			let contextKeyService = new MockContextKeyService();
			let keybindingService = new MockKeybindingService();
			let terminalFocusContextKey = contextKeyService.createKey('test', false);
			instantiationService = new TestInstantiationService();
			instantiationService.stub(IMessageService, new TestMessageService());
			instantiationService.stub(IWorkspaceContextService, new TestContextService());
			instantiationService.stub(IKeybindingService, keybindingService);
			instantiationService.stub(IContextKeyService, contextKeyService);
			instantiationService.stub(IHistoryService, new TestHistoryService());
			configHelper = {
				config: {
					cwd: null
				}
			};
			instance = instantiationService.createInstance(TestTerminalInstance, terminalFocusContextKey, configHelper, null, null);
		});
開發者ID:SeanKilleen,項目名稱:vscode,代碼行數:17,代碼來源:terminalInstance.test.ts

示例4: test

	test('Search Model: Search reports timed telemetry on search when progress is not called', () => {
		let target2 = sinon.spy();
		stub(nullEvent, 'stop', target2);
		let target1 = sinon.stub().returns(nullEvent);
		instantiationService.stub(ITelemetryService, 'publicLog', target1);

		instantiationService.stub(ISearchService, 'search', ppromiseWithProgress([]));

		let testObject = instantiationService.createInstance(SearchModel);
		const result = testObject.search({ contentPattern: { pattern: 'somestring' }, type: 1, folderQueries });

		return result.then(() => {
			return timeout(1).then(() => {
				assert.ok(target1.calledWith('searchResultsFirstRender'));
				assert.ok(target1.calledWith('searchResultsFinished'));
			});
		});
	});
開發者ID:jinlongchen2018,項目名稱:vscode,代碼行數:18,代碼來源:searchModel.test.ts

示例5: setup

	setup(() => {
		configurationService = new TestConfigurationService();
		configurationService.setUserConfiguration('terminal', {
			integrated: {
				shell: {
					linux: TERMINAL_DEFAULT_SHELL_LINUX,
					osx: TERMINAL_DEFAULT_SHELL_OSX,
					windows: TERMINAL_DEFAULT_SHELL_WINDOWS
				},
				setLocaleVariables: false
			}
		});
		instantiationService = new TestInstantiationService();
		instantiationService.stub(IContextKeyService, { createKey: () => null });
		instantiationService.stub(IConfigurationService, configurationService);
		instantiationService.stub(IInstantiationService, instantiationService);
		instantiationService.stub(IWorkspaceContextService, { getWorkspace: () => null });
		service = instantiationService.createInstance(TestTerminalService);
	});
開發者ID:StateFarmIns,項目名稱:vscode,代碼行數:19,代碼來源:terminalService.test.ts

示例6: test

	test('Search Model: Search reports timed telemetry on search when progress is not called', function (done) {
		let target2 = sinon.spy();
		stub(nullEvent, 'stop', target2);
		let target1 = sinon.stub().returns(nullEvent);
		instantiationService.stub(ITelemetryService, 'publicLog', target1);

		instantiationService.stub(ISearchService, 'search', PPromise.as({ results: [] }));

		let testObject = instantiationService.createInstance(SearchModel);
		const result = testObject.search({ contentPattern: { pattern: 'somestring' }, type: 1 });

		setTimeout(() => {
			result.done(() => {
				assert.ok(target1.calledWith('searchResultsFirstRender'));
				assert.ok(target1.calledWith('searchResultsFinished'));

				done();
			});
		}, 0);
	});
開發者ID:FabianLauer,項目名稱:vscode,代碼行數:20,代碼來源:searchModel.test.ts

示例7: test

	test('Data Source', function () {
		let ds = new SearchDataSource();
		let result = instantiation.createInstance(SearchResult, null);
		result.add([{
			resource: uri.parse('file:///c:/foo'),
			lineMatches: [{ lineNumber: 1, preview: 'bar', offsetAndLengths: [[0, 1]] }]
		}]);

		let fileMatch = result.matches()[0];
		let lineMatch = fileMatch.matches()[0];

		assert.equal(ds.getId(null, result), 'root');
		assert.equal(ds.getId(null, fileMatch), 'file:///c%3A/foo');
		assert.equal(ds.getId(null, lineMatch), 'file:///c%3A/foo>1>0b');

		assert(!ds.hasChildren(null, 'foo'));
		assert(ds.hasChildren(null, result));
		assert(ds.hasChildren(null, fileMatch));
		assert(!ds.hasChildren(null, lineMatch));
	});
開發者ID:FabianLauer,項目名稱:vscode,代碼行數:20,代碼來源:searchViewlet.test.ts

示例8: test

	test('Search Model: Search reports timed telemetry on search when error is cancelled error', function () {
		let target2 = sinon.spy();
		stub(nullEvent, 'stop', target2);
		let target1 = sinon.stub().returns(nullEvent);
		instantiationService.stub(ITelemetryService, 'publicLog', target1);

		let promise = new DeferredPPromise<ISearchComplete, ISearchProgressItem>();
		instantiationService.stub(ISearchService, 'search', promise);

		let testObject = instantiationService.createInstance(SearchModel);
		let result = testObject.search({ contentPattern: { pattern: 'somestring' }, type: 1, folderQueries });

		promise.cancel();

		return timeout(1).then(() => {
			return result.then(() => { }, () => {
				assert.ok(target1.calledWith('searchResultsFirstRender'));
				assert.ok(target1.calledWith('searchResultsFinished'));
				// assert.ok(target2.calledOnce);
			});
		});
	});
開發者ID:AllureFer,項目名稱:vscode,代碼行數:22,代碼來源:searchModel.test.ts

示例9: test

	test('Show experimental prompt if experiment should be run. Choosing an option should mark experiment as complete', () => {

		storageData = {
			enabled: true,
			state: ExperimentState.Run
		};

		instantiationService.stub(INotificationService, {
			prompt: (a: Severity, b: string, c: IPromptChoice[], d) => {
				assert.equal(b, promptText);
				assert.equal(c.length, 2);
				c[0].run();
			}
		});

		experimentalPrompt = instantiationService.createInstance(ExperimentalPrompts);
		onExperimentEnabledEvent.fire(experiment);

		return TPromise.as(null).then(result => {
			assert.equal(storageData['state'], ExperimentState.Complete);
		});

	});
開發者ID:burhandodhy,項目名稱:azuredatastudio,代碼行數:23,代碼來源:experimentalPrompts.test.ts


注:本文中的vs/platform/instantiation/test/common/instantiationServiceMock.TestInstantiationService.createInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。