提交 a6e6fb20 编写于 作者: M Matt Bierner

Avoid any in TestInstantiationService.stub

Use of any in stub was causing a few issues:
- Lots of implicit anys being used
- Methods / properties being stubbed with wrong types
- Non-existant methods/properties being stubbed

The fix is to require that the passed in stub is either a `Function` (the ctor case) or a `partial` of the type being stubbed.
上级 eac04831
...@@ -35,12 +35,12 @@ export class TestInstantiationService extends InstantiationService { ...@@ -35,12 +35,12 @@ export class TestInstantiationService extends InstantiationService {
return <T>this._create(service, { mock: true }); return <T>this._create(service, { mock: true });
} }
public stub<T>(service: ServiceIdentifier<T>, ctor?: any): T; public stub<T>(service: ServiceIdentifier<T>, ctor: Function): T;
public stub<T>(service: ServiceIdentifier<T>, obj?: any): T; public stub<T>(service: ServiceIdentifier<T>, obj: Partial<T>): T;
public stub<T>(service: ServiceIdentifier<T>, ctor?: any, property?: string, value?: any): sinon.SinonStub; public stub<T>(service: ServiceIdentifier<T>, ctor: Function, property: string, value: any): sinon.SinonStub;
public stub<T>(service: ServiceIdentifier<T>, obj?: any, property?: string, value?: any): sinon.SinonStub; public stub<T>(service: ServiceIdentifier<T>, obj: Partial<T>, property: string, value: any): sinon.SinonStub;
public stub<T>(service: ServiceIdentifier<T>, property?: string, value?: any): sinon.SinonStub; public stub<T>(service: ServiceIdentifier<T>, property: string, value: any): sinon.SinonStub;
public stub<T>(serviceIdentifier: ServiceIdentifier<T>, arg2?: any, arg3?: string, arg4?: any): sinon.SinonStub { public stub<T>(serviceIdentifier: ServiceIdentifier<T>, arg2: any, arg3?: string, arg4?: any): sinon.SinonStub {
let service = typeof arg2 !== 'string' ? arg2 : undefined; let service = typeof arg2 !== 'string' ? arg2 : undefined;
let serviceMock: IServiceMock<any> = { id: serviceIdentifier, service: service }; let serviceMock: IServiceMock<any> = { id: serviceIdentifier, service: service };
let property = typeof arg2 === 'string' ? arg2 : arg3; let property = typeof arg2 === 'string' ? arg2 : arg3;
......
...@@ -24,7 +24,7 @@ import { TestConfigurationService } from 'vs/platform/configuration/test/common/ ...@@ -24,7 +24,7 @@ import { TestConfigurationService } from 'vs/platform/configuration/test/common/
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle'; import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { assign } from 'vs/base/common/objects'; import { assign } from 'vs/base/common/objects';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import { IStorageService } from 'vs/platform/storage/common/storage'; import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { lastSessionDateStorageKey } from 'vs/platform/telemetry/node/workbenchCommonProperties'; import { lastSessionDateStorageKey } from 'vs/platform/telemetry/node/workbenchCommonProperties';
import { getGalleryExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil'; import { getGalleryExtensionId } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { ExtensionType } from 'vs/platform/extensions/common/extensions'; import { ExtensionType } from 'vs/platform/extensions/common/extensions';
...@@ -86,11 +86,11 @@ suite('Experiment Service', () => { ...@@ -86,11 +86,11 @@ suite('Experiment Service', () => {
testConfigurationService = new TestConfigurationService(); testConfigurationService = new TestConfigurationService();
instantiationService.stub(IConfigurationService, testConfigurationService); instantiationService.stub(IConfigurationService, testConfigurationService);
instantiationService.stub(ILifecycleService, new TestLifecycleService()); instantiationService.stub(ILifecycleService, new TestLifecycleService());
instantiationService.stub(IStorageService, { get: (a, b, c) => c, getBoolean: (a, b, c) => c, store: () => { }, remove: () => { } }); instantiationService.stub(IStorageService, <Partial<IStorageService>>{ get: (a: string, b: StorageScope, c?: string) => c, getBoolean: (a: string, b: StorageScope, c?: boolean) => c, store: () => { }, remove: () => { } });
setup(() => { setup(() => {
instantiationService.stub(IEnvironmentService, {}); instantiationService.stub(IEnvironmentService, {});
instantiationService.stub(IStorageService, { get: (a, b, c) => c, getBoolean: (a, b, c) => c, store: () => { }, remove: () => { } }); instantiationService.stub(IStorageService, <Partial<IStorageService>>{ get: (a: string, b: StorageScope, c?: string) => c, getBoolean: (a: string, b: StorageScope, c?: boolean) => c, store: () => { }, remove: () => { } });
}); });
teardown(() => { teardown(() => {
...@@ -196,11 +196,11 @@ suite('Experiment Service', () => { ...@@ -196,11 +196,11 @@ suite('Experiment Service', () => {
] ]
}; };
instantiationService.stub(IStorageService, { instantiationService.stub(IStorageService, <Partial<IStorageService>>{
get: (a, b, c) => { get: (a: string, b: StorageScope, c?: string) => {
return a === lastSessionDateStorageKey ? 'some-date' : undefined; return a === lastSessionDateStorageKey ? 'some-date' : undefined;
}, },
getBoolean: (a, b, c) => c, store: () => { }, remove: () => { } getBoolean: (a: string, b: StorageScope, c?: boolean) => c, store: () => { }, remove: () => { }
}); });
testObject = instantiationService.createInstance(TestExperimentService); testObject = instantiationService.createInstance(TestExperimentService);
return testObject.getExperimentById('experiment1').then(result => { return testObject.getExperimentById('experiment1').then(result => {
...@@ -240,11 +240,11 @@ suite('Experiment Service', () => { ...@@ -240,11 +240,11 @@ suite('Experiment Service', () => {
] ]
}; };
instantiationService.stub(IStorageService, { instantiationService.stub(IStorageService, <Partial<IStorageService>>{
get: (a, b, c) => { get: (a: string, b: StorageScope, c: string | undefined) => {
return a === lastSessionDateStorageKey ? 'some-date' : undefined; return a === lastSessionDateStorageKey ? 'some-date' : undefined;
}, },
getBoolean: (a, b, c) => c, store: () => { }, remove: () => { } getBoolean: (a: string, b: StorageScope, c?: boolean) => c, store: () => { }, remove: () => { }
}); });
testObject = instantiationService.createInstance(TestExperimentService); testObject = instantiationService.createInstance(TestExperimentService);
return testObject.getExperimentById('experiment1').then(result => { return testObject.getExperimentById('experiment1').then(result => {
...@@ -372,9 +372,9 @@ suite('Experiment Service', () => { ...@@ -372,9 +372,9 @@ suite('Experiment Service', () => {
] ]
}; };
instantiationService.stub(IStorageService, { instantiationService.stub(IStorageService, <Partial<IStorageService>>{
get: (a, b, c) => a === 'experiments.experiment1' ? JSON.stringify({ state: ExperimentState.Complete }) : c, get: (a: string, b: StorageScope, c?: string) => a === 'experiments.experiment1' ? JSON.stringify({ state: ExperimentState.Complete }) : c,
store: (a, b, c) => { } store: () => { }
}); });
testObject = instantiationService.createInstance(TestExperimentService); testObject = instantiationService.createInstance(TestExperimentService);
...@@ -400,9 +400,9 @@ suite('Experiment Service', () => { ...@@ -400,9 +400,9 @@ suite('Experiment Service', () => {
] ]
}; };
instantiationService.stub(IStorageService, { instantiationService.stub(IStorageService, <Partial<IStorageService>>{
get: (a, b, c) => a === 'experiments.experiment1' ? JSON.stringify({ enabled: true, state: ExperimentState.Run }) : c, get: (a: string, b: StorageScope, c?: string) => a === 'experiments.experiment1' ? JSON.stringify({ enabled: true, state: ExperimentState.Run }) : c,
store: (a, b, c) => { } store: () => { }
}); });
testObject = instantiationService.createInstance(TestExperimentService); testObject = instantiationService.createInstance(TestExperimentService);
return testObject.getExperimentById('experiment1').then(result => { return testObject.getExperimentById('experiment1').then(result => {
...@@ -508,8 +508,8 @@ suite('Experiment Service', () => { ...@@ -508,8 +508,8 @@ suite('Experiment Service', () => {
let storageDataExperiment1: ExperimentSettings | null = { enabled: false }; let storageDataExperiment1: ExperimentSettings | null = { enabled: false };
let storageDataExperiment2: ExperimentSettings | null = { enabled: false }; let storageDataExperiment2: ExperimentSettings | null = { enabled: false };
let storageDataAllExperiments: string[] | null = ['experiment1', 'experiment2', 'experiment3']; let storageDataAllExperiments: string[] | null = ['experiment1', 'experiment2', 'experiment3'];
instantiationService.stub(IStorageService, { instantiationService.stub(IStorageService, <Partial<IStorageService>>{
get: (a, b, c) => { get: (a: string, b: StorageScope, c?: string) => {
switch (a) { switch (a) {
case 'experiments.experiment1': case 'experiments.experiment1':
return JSON.stringify(storageDataExperiment1); return JSON.stringify(storageDataExperiment1);
...@@ -522,7 +522,7 @@ suite('Experiment Service', () => { ...@@ -522,7 +522,7 @@ suite('Experiment Service', () => {
} }
return c; return c;
}, },
store: (a, b, c) => { store: (a: string, b: any, c: StorageScope) => {
switch (a) { switch (a) {
case 'experiments.experiment1': case 'experiments.experiment1':
storageDataExperiment1 = JSON.parse(b); storageDataExperiment1 = JSON.parse(b);
...@@ -537,7 +537,7 @@ suite('Experiment Service', () => { ...@@ -537,7 +537,7 @@ suite('Experiment Service', () => {
break; break;
} }
}, },
remove: a => { remove: (a: string) => {
switch (a) { switch (a) {
case 'experiments.experiment1': case 'experiments.experiment1':
storageDataExperiment1 = null; storageDataExperiment1 = null;
...@@ -580,8 +580,8 @@ suite('Experiment Service', () => { ...@@ -580,8 +580,8 @@ suite('Experiment Service', () => {
let storageDataExperiment3: ExperimentSettings | null = { enabled: true, state: ExperimentState.Evaluating }; let storageDataExperiment3: ExperimentSettings | null = { enabled: true, state: ExperimentState.Evaluating };
let storageDataExperiment4: ExperimentSettings | null = { enabled: true, state: ExperimentState.Complete }; let storageDataExperiment4: ExperimentSettings | null = { enabled: true, state: ExperimentState.Complete };
let storageDataAllExperiments: string[] | null = ['experiment1', 'experiment2', 'experiment3', 'experiment4']; let storageDataAllExperiments: string[] | null = ['experiment1', 'experiment2', 'experiment3', 'experiment4'];
instantiationService.stub(IStorageService, { instantiationService.stub(IStorageService, <Partial<IStorageService>>{
get: (a, b, c) => { get: (a: string, b: StorageScope, c?: string) => {
switch (a) { switch (a) {
case 'experiments.experiment1': case 'experiments.experiment1':
return JSON.stringify(storageDataExperiment1); return JSON.stringify(storageDataExperiment1);
...@@ -601,19 +601,19 @@ suite('Experiment Service', () => { ...@@ -601,19 +601,19 @@ suite('Experiment Service', () => {
store: (a, b, c) => { store: (a, b, c) => {
switch (a) { switch (a) {
case 'experiments.experiment1': case 'experiments.experiment1':
storageDataExperiment1 = JSON.parse(b); storageDataExperiment1 = JSON.parse(b + '');
break; break;
case 'experiments.experiment2': case 'experiments.experiment2':
storageDataExperiment2 = JSON.parse(b); storageDataExperiment2 = JSON.parse(b + '');
break; break;
case 'experiments.experiment3': case 'experiments.experiment3':
storageDataExperiment3 = JSON.parse(b); storageDataExperiment3 = JSON.parse(b + '');
break; break;
case 'experiments.experiment4': case 'experiments.experiment4':
storageDataExperiment4 = JSON.parse(b); storageDataExperiment4 = JSON.parse(b + '');
break; break;
case 'allExperiments': case 'allExperiments':
storageDataAllExperiments = JSON.parse(b); storageDataAllExperiments = JSON.parse(b + '');
break; break;
default: default:
break; break;
...@@ -768,8 +768,8 @@ suite('Experiment Service', () => { ...@@ -768,8 +768,8 @@ suite('Experiment Service', () => {
let storageDataExperiment3 = { enabled: true, state: ExperimentState.Evaluating }; let storageDataExperiment3 = { enabled: true, state: ExperimentState.Evaluating };
let storageDataExperiment4 = { enabled: true, state: ExperimentState.Evaluating }; let storageDataExperiment4 = { enabled: true, state: ExperimentState.Evaluating };
instantiationService.stub(IStorageService, { instantiationService.stub(IStorageService, <Partial<IStorageService>>{
get: (a, b, c) => { get: (a: string, b: StorageScope, c?: string) => {
switch (a) { switch (a) {
case 'currentOrPreviouslyRunExperiments': case 'currentOrPreviouslyRunExperiments':
return JSON.stringify(['experiment1', 'experiment2']); return JSON.stringify(['experiment1', 'experiment2']);
...@@ -781,10 +781,10 @@ suite('Experiment Service', () => { ...@@ -781,10 +781,10 @@ suite('Experiment Service', () => {
store: (a, b, c) => { store: (a, b, c) => {
switch (a) { switch (a) {
case 'experiments.experiment3': case 'experiments.experiment3':
storageDataExperiment3 = JSON.parse(b); storageDataExperiment3 = JSON.parse(b + '');
break; break;
case 'experiments.experiment4': case 'experiments.experiment4':
storageDataExperiment4 = JSON.parse(b); storageDataExperiment4 = JSON.parse(b + '');
break; break;
default: default:
break; break;
......
...@@ -95,6 +95,7 @@ suite('Experimental Prompts', () => { ...@@ -95,6 +95,7 @@ suite('Experimental Prompts', () => {
assert.equal(b, promptText); assert.equal(b, promptText);
assert.equal(c.length, 2); assert.equal(c.length, 2);
c[0].run(); c[0].run();
return undefined!;
} }
}); });
...@@ -119,6 +120,7 @@ suite('Experimental Prompts', () => { ...@@ -119,6 +120,7 @@ suite('Experimental Prompts', () => {
assert.equal(b, promptText); assert.equal(b, promptText);
assert.equal(c.length, 2); assert.equal(c.length, 2);
c[1].run(); c[1].run();
return undefined!;
} }
}); });
...@@ -143,6 +145,7 @@ suite('Experimental Prompts', () => { ...@@ -143,6 +145,7 @@ suite('Experimental Prompts', () => {
assert.equal(b, promptText); assert.equal(b, promptText);
assert.equal(c.length, 2); assert.equal(c.length, 2);
options.onCancel(); options.onCancel();
return undefined!;
} }
}); });
......
...@@ -228,7 +228,7 @@ suite('ExtensionsTipsService Test', () => { ...@@ -228,7 +228,7 @@ suite('ExtensionsTipsService Test', () => {
}); });
setup(() => { setup(() => {
instantiationService.stub(IEnvironmentService, { extensionDevelopmentPath: false }); instantiationService.stub(IEnvironmentService, <Partial<IEnvironmentService>>{ extensionDevelopmentPath: false });
instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', []); instantiationService.stubPromise(IExtensionManagementService, 'getInstalled', []);
instantiationService.stub(IExtensionGalleryService, 'isEnabled', true); instantiationService.stub(IExtensionGalleryService, 'isEnabled', true);
instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage<IGalleryExtension>(...mockExtensionGallery)); instantiationService.stubPromise(IExtensionGalleryService, 'query', aPage<IGalleryExtension>(...mockExtensionGallery));
...@@ -245,7 +245,7 @@ suite('ExtensionsTipsService Test', () => { ...@@ -245,7 +245,7 @@ suite('ExtensionsTipsService Test', () => {
instantiationService.stub(INotificationService, new TestNotificationService2()); instantiationService.stub(INotificationService, new TestNotificationService2());
testConfigurationService.setUserConfiguration(ConfigurationKey, { ignoreRecommendations: false, showRecommendationsOnlyOnDemand: false }); testConfigurationService.setUserConfiguration(ConfigurationKey, { ignoreRecommendations: false, showRecommendationsOnlyOnDemand: false });
instantiationService.stub(IStorageService, { get: (a: string, b: StorageScope, c?: string) => c, getBoolean: (a: string, b: StorageScope, c: boolean) => c, store: () => { } }); instantiationService.stub(IStorageService, <Partial<IStorageService>>{ get: (a: string, b: StorageScope, c?: string) => c, getBoolean: (a: string, b: StorageScope, c: boolean) => c, store: () => { } });
instantiationService.stub(IModelService, <IModelService>{ instantiationService.stub(IModelService, <IModelService>{
getModels(): any { return []; }, getModels(): any { return []; },
onModelAdded: onModelAddedEvent.event onModelAdded: onModelAddedEvent.event
...@@ -315,7 +315,7 @@ suite('ExtensionsTipsService Test', () => { ...@@ -315,7 +315,7 @@ suite('ExtensionsTipsService Test', () => {
}); });
test('ExtensionTipsService: No Prompt for valid workspace recommendations during extension development', () => { test('ExtensionTipsService: No Prompt for valid workspace recommendations during extension development', () => {
instantiationService.stub(IEnvironmentService, { extensionDevelopmentLocationURI: true }); instantiationService.stub(IEnvironmentService, { extensionDevelopmentLocationURI: URI.file('/folder/file') });
return testNoPromptOrRecommendationsForValidRecommendations(mockTestData.validRecommendedExtensions); return testNoPromptOrRecommendationsForValidRecommendations(mockTestData.validRecommendedExtensions);
}); });
...@@ -366,7 +366,7 @@ suite('ExtensionsTipsService Test', () => { ...@@ -366,7 +366,7 @@ suite('ExtensionsTipsService Test', () => {
}); });
test('ExtensionTipsService: No Prompt for valid workspace recommendations if ignoreRecommendations is set for current workspace', () => { test('ExtensionTipsService: No Prompt for valid workspace recommendations if ignoreRecommendations is set for current workspace', () => {
instantiationService.stub(IStorageService, { get: (a: string, b: StorageScope, c?: string) => c, getBoolean: (a: string, b: StorageScope, c?: boolean) => a === 'extensionsAssistant/workspaceRecommendationsIgnore' || c }); instantiationService.stub(IStorageService, <Partial<IStorageService>>{ get: (a: string, b: StorageScope, c?: string) => c, getBoolean: (a: string, b: StorageScope, c?: boolean) => a === 'extensionsAssistant/workspaceRecommendationsIgnore' || c });
return testNoPromptForValidRecommendations(mockTestData.validRecommendedExtensions); return testNoPromptForValidRecommendations(mockTestData.validRecommendedExtensions);
}); });
...@@ -379,9 +379,9 @@ suite('ExtensionsTipsService Test', () => { ...@@ -379,9 +379,9 @@ suite('ExtensionsTipsService Test', () => {
return c; return c;
}; };
instantiationService.stub(IStorageService, { instantiationService.stub(IStorageService, <Partial<IStorageService>>{
get: storageGetterStub, get: storageGetterStub,
getBoolean: (a: string, _: StorageScope, c?: string) => a === 'extensionsAssistant/workspaceRecommendationsIgnore' || c getBoolean: (a: string, _: StorageScope, c?: boolean) => a === 'extensionsAssistant/workspaceRecommendationsIgnore' || c
}); });
return setUpFolderWorkspace('myFolder', mockTestData.validRecommendedExtensions).then(() => { return setUpFolderWorkspace('myFolder', mockTestData.validRecommendedExtensions).then(() => {
...@@ -399,7 +399,7 @@ suite('ExtensionsTipsService Test', () => { ...@@ -399,7 +399,7 @@ suite('ExtensionsTipsService Test', () => {
test('ExtensionTipsService: No Recommendations of workspace ignored recommendations', () => { test('ExtensionTipsService: No Recommendations of workspace ignored recommendations', () => {
const ignoredRecommendations = ['ms-vscode.csharp', 'mockpublisher2.mockextension2']; // ignore a stored recommendation and a workspace recommendation. const ignoredRecommendations = ['ms-vscode.csharp', 'mockpublisher2.mockextension2']; // ignore a stored recommendation and a workspace recommendation.
const storedRecommendations = '["ms-vscode.csharp", "ms-python.python"]'; const storedRecommendations = '["ms-vscode.csharp", "ms-python.python"]';
instantiationService.stub(IStorageService, { instantiationService.stub(IStorageService, <Partial<IStorageService>>{
get: (a: string, b: StorageScope, c?: string) => a === 'extensionsAssistant/recommendations' ? storedRecommendations : c, get: (a: string, b: StorageScope, c?: string) => a === 'extensionsAssistant/recommendations' ? storedRecommendations : c,
getBoolean: (a: string, _: StorageScope, c?: boolean) => a === 'extensionsAssistant/workspaceRecommendationsIgnore' || c getBoolean: (a: string, _: StorageScope, c?: boolean) => a === 'extensionsAssistant/workspaceRecommendationsIgnore' || c
}); });
...@@ -427,7 +427,7 @@ suite('ExtensionsTipsService Test', () => { ...@@ -427,7 +427,7 @@ suite('ExtensionsTipsService Test', () => {
}; };
const workspaceIgnoredRecommendations = ['ms-vscode.csharp']; // ignore a stored recommendation and a workspace recommendation. const workspaceIgnoredRecommendations = ['ms-vscode.csharp']; // ignore a stored recommendation and a workspace recommendation.
instantiationService.stub(IStorageService, { instantiationService.stub(IStorageService, <Partial<IStorageService>>{
get: storageGetterStub, get: storageGetterStub,
getBoolean: (a: string, _: StorageScope, c?: boolean) => a === 'extensionsAssistant/workspaceRecommendationsIgnore' || c getBoolean: (a: string, _: StorageScope, c?: boolean) => a === 'extensionsAssistant/workspaceRecommendationsIgnore' || c
}); });
...@@ -453,7 +453,7 @@ suite('ExtensionsTipsService Test', () => { ...@@ -453,7 +453,7 @@ suite('ExtensionsTipsService Test', () => {
return c; return c;
}; };
instantiationService.stub(IStorageService, { instantiationService.stub(IStorageService, <Partial<IStorageService>>{
get: storageGetterStub, get: storageGetterStub,
store: () => { }, store: () => { },
getBoolean: (a: string, _: StorageScope, c?: boolean) => a === 'extensionsAssistant/workspaceRecommendationsIgnore' || c getBoolean: (a: string, _: StorageScope, c?: boolean) => a === 'extensionsAssistant/workspaceRecommendationsIgnore' || c
...@@ -491,7 +491,7 @@ suite('ExtensionsTipsService Test', () => { ...@@ -491,7 +491,7 @@ suite('ExtensionsTipsService Test', () => {
const storageSetterTarget = sinon.spy(); const storageSetterTarget = sinon.spy();
const changeHandlerTarget = sinon.spy(); const changeHandlerTarget = sinon.spy();
const ignoredExtensionId = 'Some.Extension'; const ignoredExtensionId = 'Some.Extension';
instantiationService.stub(IStorageService, { instantiationService.stub(IStorageService, <Partial<IStorageService>>{
get: (a: string, b: StorageScope, c?: boolean) => a === 'extensionsAssistant/ignored_recommendations' ? '["ms-vscode.vscode"]' : c, get: (a: string, b: StorageScope, c?: boolean) => a === 'extensionsAssistant/ignored_recommendations' ? '["ms-vscode.vscode"]' : c,
store: (...args: any[]) => { store: (...args: any[]) => {
storageSetterTarget(...args); storageSetterTarget(...args);
...@@ -511,7 +511,7 @@ suite('ExtensionsTipsService Test', () => { ...@@ -511,7 +511,7 @@ suite('ExtensionsTipsService Test', () => {
test('ExtensionTipsService: Get file based recommendations from storage (old format)', () => { test('ExtensionTipsService: Get file based recommendations from storage (old format)', () => {
const storedRecommendations = '["ms-vscode.csharp", "ms-python.python", "ms-vscode.vscode-typescript-tslint-plugin"]'; const storedRecommendations = '["ms-vscode.csharp", "ms-python.python", "ms-vscode.vscode-typescript-tslint-plugin"]';
instantiationService.stub(IStorageService, { get: (a: string, b: StorageScope, c?: string) => a === 'extensionsAssistant/recommendations' ? storedRecommendations : c }); instantiationService.stub(IStorageService, <Partial<IStorageService>>{ get: (a: string, b: StorageScope, c?: string) => a === 'extensionsAssistant/recommendations' ? storedRecommendations : c });
return setUpFolderWorkspace('myFolder', []).then(() => { return setUpFolderWorkspace('myFolder', []).then(() => {
testObject = instantiationService.createInstance(ExtensionTipsService); testObject = instantiationService.createInstance(ExtensionTipsService);
...@@ -530,7 +530,7 @@ suite('ExtensionsTipsService Test', () => { ...@@ -530,7 +530,7 @@ suite('ExtensionsTipsService Test', () => {
const now = Date.now(); const now = Date.now();
const tenDaysOld = 10 * milliSecondsInADay; const tenDaysOld = 10 * milliSecondsInADay;
const storedRecommendations = `{"ms-vscode.csharp": ${now}, "ms-python.python": ${now}, "ms-vscode.vscode-typescript-tslint-plugin": ${now}, "lukehoban.Go": ${tenDaysOld}}`; const storedRecommendations = `{"ms-vscode.csharp": ${now}, "ms-python.python": ${now}, "ms-vscode.vscode-typescript-tslint-plugin": ${now}, "lukehoban.Go": ${tenDaysOld}}`;
instantiationService.stub(IStorageService, { get: (a: string, b: StorageScope, c?: string) => a === 'extensionsAssistant/recommendations' ? storedRecommendations : c }); instantiationService.stub(IStorageService, <Partial<IStorageService>>{ get: (a: string, b: StorageScope, c?: string) => a === 'extensionsAssistant/recommendations' ? storedRecommendations : c });
return setUpFolderWorkspace('myFolder', []).then(() => { return setUpFolderWorkspace('myFolder', []).then(() => {
testObject = instantiationService.createInstance(ExtensionTipsService); testObject = instantiationService.createInstance(ExtensionTipsService);
......
...@@ -124,7 +124,7 @@ suite('ExtensionsListView Tests', () => { ...@@ -124,7 +124,7 @@ suite('ExtensionsListView Tests', () => {
instantiationService.stubPromise(IExperimentService, 'getExperimentsByType', []); instantiationService.stubPromise(IExperimentService, 'getExperimentsByType', []);
instantiationService.stub(IExtensionService, { instantiationService.stub(IExtensionService, {
getExtensions: () => { getExtensions: (): any => { // TODO remove any
return Promise.resolve([ return Promise.resolve([
{ identifier: new ExtensionIdentifier(localEnabledTheme.identifier.id) }, { identifier: new ExtensionIdentifier(localEnabledTheme.identifier.id) },
{ identifier: new ExtensionIdentifier(localEnabledLanguage.identifier.id) }, { identifier: new ExtensionIdentifier(localEnabledLanguage.identifier.id) },
......
...@@ -70,10 +70,8 @@ suite('ExtensionsWorkbenchServiceTest', () => { ...@@ -70,10 +70,8 @@ suite('ExtensionsWorkbenchServiceTest', () => {
instantiationService.stub(IWorkspaceContextService, new TestContextService()); instantiationService.stub(IWorkspaceContextService, new TestContextService());
instantiationService.stub(IConfigurationService, { instantiationService.stub(IConfigurationService, {
onDidUpdateConfiguration: () => { }, onDidChangeConfiguration: () => { return undefined!; },
onDidChangeConfiguration: () => { }, getValue: (key?) => {
getConfiguration: () => ({}),
getValue: (key) => {
return (key === AutoCheckUpdatesConfigurationKey || key === AutoUpdateConfigurationKey) ? true : undefined; return (key === AutoCheckUpdatesConfigurationKey || key === AutoUpdateConfigurationKey) ? true : undefined;
} }
}); });
...@@ -91,7 +89,7 @@ suite('ExtensionsWorkbenchServiceTest', () => { ...@@ -91,7 +89,7 @@ suite('ExtensionsWorkbenchServiceTest', () => {
instantiationService.set(IExtensionTipsService, instantiationService.createInstance(ExtensionTipsService)); instantiationService.set(IExtensionTipsService, instantiationService.createInstance(ExtensionTipsService));
instantiationService.stub(INotificationService, { prompt: () => null }); instantiationService.stub(INotificationService, { prompt: () => null! });
}); });
setup(async () => { setup(async () => {
......
...@@ -9,24 +9,14 @@ import { IStorageService } from 'vs/platform/storage/common/storage'; ...@@ -9,24 +9,14 @@ import { IStorageService } from 'vs/platform/storage/common/storage';
suite('Workbench - GettingStarted', () => { suite('Workbench - GettingStarted', () => {
let instantiation: TestInstantiationService | null = null; let instantiation: TestInstantiationService | null = null;
let welcomePageEnvConfig: string | null = null;
let hideWelcomeSettingsValue: string | null = null; let hideWelcomeSettingsValue: string | null = null;
// let machineId: string | null = null;
let appName: string | null = null;
suiteSetup(() => { suiteSetup(() => {
instantiation = new TestInstantiationService(); instantiation = new TestInstantiationService();
instantiation.stub(IWorkspaceContextService, { instantiation.stub(IWorkspaceContextService, {
getConfiguration: () => {
return {
env: {
welcomePage: welcomePageEnvConfig,
appName: appName
}
};
}
}); });
instantiation.stub(IStorageService, { instantiation.stub(IStorageService, <Partial<IStorageService>>{
get: () => hideWelcomeSettingsValue, get: () => hideWelcomeSettingsValue,
store: (value) => hideWelcomeSettingsValue = value store: (value) => hideWelcomeSettingsValue = value
}); });
...@@ -37,8 +27,6 @@ suite('Workbench - GettingStarted', () => { ...@@ -37,8 +27,6 @@ suite('Workbench - GettingStarted', () => {
}); });
setup(() => { setup(() => {
welcomePageEnvConfig = null;
hideWelcomeSettingsValue = null; hideWelcomeSettingsValue = null;
appName = null;
}); });
}); });
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册