1 | import * as sinon from 'sinon';
|
2 | import { SinonSpy } from 'sinon';
|
3 | export { sinon, SinonSpy };
|
4 | export declare type StubbedInstanceWithSinonAccessor<T> = T & {
|
5 | stubs: sinon.SinonStubbedInstance<T>;
|
6 | };
|
7 | /**
|
8 | * Creates a new object with the given functions as the prototype and stubs all
|
9 | * implemented functions.
|
10 | *
|
11 | * Note: The given constructor function is not invoked. See also the stub API.
|
12 | *
|
13 | * This is a helper method replacing `sinon.createStubInstance` and working
|
14 | * around the limitations of TypeScript and Sinon, where Sinon is not able to
|
15 | * list private/protected members in the type definition of the stub instance
|
16 | * and therefore the stub instance cannot be assigned to places expecting TType.
|
17 | * See also
|
18 | * - https://github.com/Microsoft/TypeScript/issues/13543
|
19 | * - https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14811
|
20 | *
|
21 | * @typeParam TType - Type being stubbed.
|
22 | * @param constructor - Object or class to stub.
|
23 | * @returns A stubbed version of the constructor, with an extra property `stubs`
|
24 | * providing access to stub API for individual methods.
|
25 | */
|
26 | export declare function createStubInstance<TType>(constructor: sinon.StubbableType<TType>): StubbedInstanceWithSinonAccessor<TType>;
|