From c51f346db414ce8ff5e2e220c17090ed84b45e65 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Tue, 23 Oct 2018 14:00:25 +0200 Subject: [PATCH] debt - more less TPromise --- .../test/common/commandService.test.ts | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/vs/workbench/services/commands/test/common/commandService.test.ts b/src/vs/workbench/services/commands/test/common/commandService.test.ts index a3228f90fe9..a4ffab9c342 100644 --- a/src/vs/workbench/services/commands/test/common/commandService.test.ts +++ b/src/vs/workbench/services/commands/test/common/commandService.test.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import * as assert from 'assert'; import { IDisposable } from 'vs/base/common/lifecycle'; -import { TPromise } from 'vs/base/common/winjs.base'; import { CommandsRegistry } from 'vs/platform/commands/common/commands'; import { CommandService } from 'vs/workbench/services/commands/common/commandService'; import { IExtensionService, ExtensionPointContribution, IExtensionDescription, ProfileSession } from 'vs/workbench/services/extensions/common/extensions'; @@ -21,25 +20,25 @@ class SimpleExtensionService implements IExtensionService { return this._onDidRegisterExtensions.event; } onDidChangeExtensionsStatus = null; - activateByEvent(activationEvent: string): TPromise { + activateByEvent(activationEvent: string): Promise { return this.whenInstalledExtensionsRegistered().then(() => { }); } - whenInstalledExtensionsRegistered(): TPromise { - return TPromise.as(true); + whenInstalledExtensionsRegistered(): Promise { + return Promise.resolve(true); } - readExtensionPointContributions(extPoint: IExtensionPoint): TPromise[]> { - return TPromise.as([]); + readExtensionPointContributions(extPoint: IExtensionPoint): Promise[]> { + return Promise.resolve([]); } getExtensionsStatus() { return undefined; } - getExtensions(): TPromise { - return TPromise.wrap([]); + getExtensions(): Promise { + return Promise.resolve([]); } canProfileExtensionHost() { return false; } - startExtensionHostProfile(): TPromise { + startExtensionHostProfile(): Promise { throw new Error('Not implemented'); } getInspectPort(): number { @@ -81,7 +80,7 @@ suite('CommandService', function () { let lastEvent: string; let service = new CommandService(new InstantiationService(), new class extends SimpleExtensionService { - activateByEvent(activationEvent: string): TPromise { + activateByEvent(activationEvent: string): Promise { lastEvent = activationEvent; return super.activateByEvent(activationEvent); } @@ -97,13 +96,17 @@ suite('CommandService', function () { }); }); - test('fwd activation error', function () { + test('fwd activation error', async function () { - let service = new CommandService(new InstantiationService(), new class extends SimpleExtensionService { - activateByEvent(activationEvent: string): TPromise { - return TPromise.wrapError(new Error('bad_activate')); + const extensionService = new class extends SimpleExtensionService { + activateByEvent(activationEvent: string): Promise { + return Promise.reject(new Error('bad_activate')); } - }, new NullLogService(), progressService); + }; + + let service = new CommandService(new InstantiationService(), extensionService, new NullLogService(), progressService); + + await extensionService.whenInstalledExtensionsRegistered(); return service.executeCommand('foo').then(() => assert.ok(false), err => { assert.equal(err.message, 'bad_activate'); @@ -117,7 +120,7 @@ suite('CommandService', function () { let service = new CommandService(new InstantiationService(), new class extends SimpleExtensionService { whenInstalledExtensionsRegistered() { - return new TPromise(_resolve => { /*ignore*/ }); + return new Promise(_resolve => { /*ignore*/ }); } }, new NullLogService(), progressService); @@ -130,7 +133,7 @@ suite('CommandService', function () { let callCounter = 0; let resolveFunc: Function; - const whenInstalledExtensionsRegistered = new TPromise(_resolve => { resolveFunc = _resolve; }); + const whenInstalledExtensionsRegistered = new Promise(_resolve => { resolveFunc = _resolve; }); let service = new CommandService(new InstantiationService(), new class extends SimpleExtensionService { whenInstalledExtensionsRegistered() { -- GitLab