mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
Merge pull request #33223 from aleung/master
sinon: add overrides parameter to createStubInstance
This commit is contained in:
Vendored
+5
-1
@@ -1618,10 +1618,14 @@ declare namespace Sinon {
|
||||
*
|
||||
* @template TType Type being stubbed.
|
||||
* @param constructor Object or class to stub.
|
||||
* @param overrides An optional map overriding created stubs
|
||||
* @returns A stubbed version of the constructor.
|
||||
* @remarks The given constructor function is not invoked. See also the stub API.
|
||||
*/
|
||||
createStubInstance<TType>(constructor: StubbableType<TType>): SinonStubbedInstance<TType>;
|
||||
createStubInstance<TType>(
|
||||
constructor: StubbableType<TType>,
|
||||
overrides?: { [K in keyof TType]?: any }
|
||||
): SinonStubbedInstance<TType>;
|
||||
}
|
||||
|
||||
interface SinonApi {
|
||||
|
||||
@@ -87,6 +87,9 @@ function testSandbox() {
|
||||
const privateFooFoo: sinon.SinonStub = privateFooStubbedInstance.foo;
|
||||
const clsBar: number = stubInstance.bar;
|
||||
const privateFooBar: number = privateFooStubbedInstance.bar;
|
||||
sb.createStubInstance(cls, {
|
||||
bar: 1
|
||||
});
|
||||
}
|
||||
|
||||
function testFakeServer() {
|
||||
|
||||
Vendored
+4
-1
@@ -1707,11 +1707,14 @@ declare namespace Sinon {
|
||||
*
|
||||
* @template TType Type being stubbed.
|
||||
* @param constructor Object or class to stub.
|
||||
* @param overrides An optional map overriding created stubs
|
||||
* @returns A stubbed version of the constructor.
|
||||
* @remarks The given constructor function is not invoked. See also the stub API.
|
||||
*/
|
||||
createStubInstance<TType>(
|
||||
constructor: StubbableType<TType>
|
||||
constructor: StubbableType<TType>,
|
||||
overrides?: { [K in keyof TType]?:
|
||||
SinonStubbedMember<TType[K]> | TType[K] extends (...args: any[]) => infer R ? R : TType[K] }
|
||||
): SinonStubbedInstance<TType>;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ function testSandbox() {
|
||||
sb.replaceSetter(replaceMe, 'setter', (v) => { });
|
||||
|
||||
const cls = class {
|
||||
foo(arg1: string, arg2: number) { return 1; }
|
||||
foo(arg1: string, arg2: number): number { return 1; }
|
||||
bar: number;
|
||||
};
|
||||
const PrivateFoo = class {
|
||||
@@ -87,6 +87,10 @@ function testSandbox() {
|
||||
const privateFooFoo: sinon.SinonStub = privateFooStubbedInstance.foo;
|
||||
const clsBar: number = stubInstance.bar;
|
||||
const privateFooBar: number = privateFooStubbedInstance.bar;
|
||||
sb.createStubInstance(cls, {
|
||||
foo: (arg1: string, arg2: number) => 2,
|
||||
bar: 1
|
||||
});
|
||||
}
|
||||
|
||||
function testFakeServer() {
|
||||
|
||||
Reference in New Issue
Block a user