1 | ;
|
2 | // Copyright IBM Corp. 2018. All Rights Reserved.
|
3 | // Node module: @loopback/testlab
|
4 | // This file is licensed under the MIT License.
|
5 | // License text available at https://opensource.org/licenses/MIT
|
6 | Object.defineProperty(exports, "__esModule", { value: true });
|
7 | const sinon = require("sinon");
|
8 | exports.sinon = sinon;
|
9 | /**
|
10 | * Creates a new object with the given functions as the prototype and stubs all
|
11 | * implemented functions.
|
12 | *
|
13 | * Note: The given constructor function is not invoked. See also the stub API.
|
14 | *
|
15 | * This is a helper method replacing `sinon.createStubInstance` and working
|
16 | * around the limitations of TypeScript and Sinon, where Sinon is not able to
|
17 | * list private/protected members in the type definition of the stub instance
|
18 | * and therefore the stub instance cannot be assigned to places expecting TType.
|
19 | * See also
|
20 | * - https://github.com/Microsoft/TypeScript/issues/13543
|
21 | * - https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14811
|
22 | *
|
23 | * @typeParam TType - Type being stubbed.
|
24 | * @param constructor - Object or class to stub.
|
25 | * @returns A stubbed version of the constructor, with an extra property `stubs`
|
26 | * providing access to stub API for individual methods.
|
27 | */
|
28 | function createStubInstance(constructor) {
|
29 | const stub = sinon.createStubInstance(constructor);
|
30 | return Object.assign(stub, { stubs: stub });
|
31 | }
|
32 | exports.createStubInstance = createStubInstance;
|
33 | //# sourceMappingURL=sinon.js.map |
\ | No newline at end of file |