mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
Expanded Sinon's createStubInstance to allow a TType generic (#16730)
* Expanded Sinon's createStubInstance types
* Defaulted createStubInstance behavior to not use the better types
TType gets inferred to `{}` by default. Odd.
* Removed commented out typings
* Removed unnecessary imports from i18next-tests
* Added TS 2.2 notices
* Bumped TS versions to 2.3
* Consolidated optional types for StubbableType
* Update index.d.ts
This commit is contained in:
@@ -1,8 +1,3 @@
|
||||
/// <reference types="sinon" />
|
||||
/// <reference types="mocha" />
|
||||
/// <reference types="expect.js" />
|
||||
/// <reference types="jquery" />
|
||||
|
||||
import i18n = require("i18next");
|
||||
|
||||
i18n.init({
|
||||
|
||||
Vendored
+1
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/tubalmartin/karma-chai-sinon
|
||||
// Definitions by: Václav Ostrožlík <https://github.com/vasek17>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/// <reference types="chai" />
|
||||
import Sinon = require("sinon");
|
||||
|
||||
Vendored
+1
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/bendrucker/sinon-as-promised
|
||||
// Definitions by: igrayson <https://github.com/igrayson>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import * as s from "sinon";
|
||||
|
||||
|
||||
Vendored
+1
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/domenic/sinon-chai
|
||||
// Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid/>, Jed Mao <https://github.com/jedmao/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="chai" />
|
||||
/// <reference types="sinon" />
|
||||
|
||||
Vendored
+1
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/vitalets/sinon-chrome
|
||||
// Definitions by: Tim Perry <https://github.com/pimterry>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
/// <reference types="chrome"/>
|
||||
/// <reference types="sinon"/>
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/danawoodman/sinon-express-mock#readme
|
||||
// Definitions by: Jared Chapiewsky <https://github.com/jpchip>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import * as Sinon from "sinon";
|
||||
|
||||
|
||||
Vendored
+1
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/underscopeio/sinon-mongoose
|
||||
// Definitions by: stevehipwell <https://github.com/stevehipwell>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
import * as s from "sinon";
|
||||
|
||||
|
||||
Vendored
+1
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/substantial/sinon-stub-promise
|
||||
// Definitions by: Thiago Temple <https://github.com/vintem>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/// <reference types="sinon"/>
|
||||
|
||||
|
||||
Vendored
+1
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/sinonjs/sinon-test
|
||||
// Definitions by: Francis Saul <https://github.com/mummybot>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import * as Sinon from 'sinon';
|
||||
|
||||
|
||||
Vendored
+37
@@ -6,6 +6,7 @@
|
||||
// Nico Jansen <https://github.com/nicojs>
|
||||
// James Garbutt <https://github.com/43081j>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
// sinon uses DOM dependencies which are absent in browser-less environment like node.js
|
||||
// to avoid compiler errors this monkey patch is used
|
||||
@@ -506,10 +507,46 @@ declare namespace Sinon {
|
||||
|
||||
// Utility overridables
|
||||
interface SinonStatic {
|
||||
/**
|
||||
* Creates a new object with the given functions as the prototype and stubs all implemented functions.
|
||||
*
|
||||
* @param constructor Object or class to stub.
|
||||
* @returns A stubbed version of the constructor.
|
||||
* @remarks The given constructor function is not invoked. See also the stub API.
|
||||
*/
|
||||
createStubInstance(constructor: any): any;
|
||||
|
||||
/**
|
||||
* Creates a new object with the given functions as the prototype and stubs all implemented functions.
|
||||
*
|
||||
* @type TType Type being stubbed.
|
||||
* @param constructor Object or class to stub.
|
||||
* @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>;
|
||||
|
||||
format(obj: any): string;
|
||||
restore(object: any): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stubbed type of an object with members replaced by stubs.
|
||||
*
|
||||
* @type TType Type being stubbed.
|
||||
*/
|
||||
interface StubbableType<TType> {
|
||||
new(...args: any[]): TType;
|
||||
}
|
||||
|
||||
/**
|
||||
* An instance of a stubbed object type with members replaced by stubs.
|
||||
*
|
||||
* @type TType Object type being stubbed.
|
||||
*/
|
||||
type SinonStubbedInstance<TType> = {
|
||||
[P in keyof TType]: SinonStub;
|
||||
};
|
||||
}
|
||||
|
||||
declare const Sinon: Sinon.SinonStatic;
|
||||
|
||||
@@ -231,6 +231,7 @@ class TestCreateStubInstance {
|
||||
}
|
||||
|
||||
sinon.createStubInstance(TestCreateStubInstance).someTestMethod('some argument');
|
||||
sinon.createStubInstance<TestCreateStubInstance>(TestCreateStubInstance).someTestMethod('some argument');
|
||||
|
||||
function testGetCalls() {
|
||||
let double = sinon.spy((a: number) => a * 2);
|
||||
|
||||
Reference in New Issue
Block a user