mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 19:18:59 +01:00
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.
This commit is contained in:
@@ -35,12 +35,12 @@ export class TestInstantiationService extends InstantiationService {
|
||||
return <T>this._create(service, { mock: true });
|
||||
}
|
||||
|
||||
public stub<T>(service: ServiceIdentifier<T>, ctor?: any): T;
|
||||
public stub<T>(service: ServiceIdentifier<T>, obj?: any): T;
|
||||
public stub<T>(service: ServiceIdentifier<T>, ctor?: any, 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>, property?: string, value?: any): sinon.SinonStub;
|
||||
public stub<T>(serviceIdentifier: ServiceIdentifier<T>, arg2?: any, arg3?: string, arg4?: any): sinon.SinonStub {
|
||||
public stub<T>(service: ServiceIdentifier<T>, ctor: Function): T;
|
||||
public stub<T>(service: ServiceIdentifier<T>, obj: Partial<T>): T;
|
||||
public stub<T>(service: ServiceIdentifier<T>, ctor: Function, 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>(serviceIdentifier: ServiceIdentifier<T>, arg2: any, arg3?: string, arg4?: any): sinon.SinonStub {
|
||||
let service = typeof arg2 !== 'string' ? arg2 : undefined;
|
||||
let serviceMock: IServiceMock<any> = { id: serviceIdentifier, service: service };
|
||||
let property = typeof arg2 === 'string' ? arg2 : arg3;
|
||||
|
||||
Reference in New Issue
Block a user