mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-24 22:17:06 +08:00
Merge pull request #15321 from rationull/sinon-2
Fix for issue #15320: Updates for SinonJS 2.x API...
This commit is contained in:
17
types/sinon/index.d.ts
vendored
17
types/sinon/index.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
// Type definitions for Sinon 1.16.0
|
||||
// Type definitions for Sinon 2.1.0
|
||||
// Project: http://sinonjs.org/
|
||||
// Definitions by: William Sears <https://github.com/mrbigdog2u>
|
||||
// Definitions by: William Sears <https://github.com/mrbigdog2u>, Jonathan Little <https://github.com/rationull>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// sinon uses DOM dependencies which are absent in browserless envoronment like node.js
|
||||
@@ -96,11 +96,16 @@ declare namespace Sinon {
|
||||
|
||||
interface SinonStub extends SinonSpy {
|
||||
resetBehavior(): void;
|
||||
resetHistory(): void;
|
||||
returns(obj: any): SinonStub;
|
||||
returnsArg(index: number): SinonStub;
|
||||
returnsThis(): SinonStub;
|
||||
resolves(value: any): SinonStub;
|
||||
throws(type?: string): SinonStub;
|
||||
throws(obj: any): SinonStub;
|
||||
rejects(): SinonStub;
|
||||
rejects(errorType: string): SinonStub;
|
||||
rejects(value: any): SinonStub;
|
||||
callsArg(index: number): SinonStub;
|
||||
callThrough(): SinonStub;
|
||||
callsArgOn(index: number, context: any): SinonStub;
|
||||
@@ -369,6 +374,7 @@ declare namespace Sinon {
|
||||
array: SinonMatcher;
|
||||
regexp: SinonMatcher;
|
||||
date: SinonMatcher;
|
||||
symbol: SinonMatcher;
|
||||
same(obj: any): SinonMatcher;
|
||||
typeOf(type: string): SinonMatcher;
|
||||
instanceOf(type: any): SinonMatcher;
|
||||
@@ -421,17 +427,10 @@ declare namespace Sinon {
|
||||
(...args: any[]): any;
|
||||
}
|
||||
|
||||
interface SinonStatic {
|
||||
config: SinonTestConfig;
|
||||
test(fn: (...args: any[]) => any): SinonTestWrapper;
|
||||
testCase(tests: any): any;
|
||||
}
|
||||
|
||||
// Utility overridables
|
||||
interface SinonStatic {
|
||||
createStubInstance(constructor: any): any;
|
||||
format(obj: any): string;
|
||||
log(message: string): void;
|
||||
restore(object: any): void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,23 @@ function testSandbox() {
|
||||
sandbox.restore();
|
||||
}
|
||||
|
||||
function testPromises() {
|
||||
var resolveStub = sinon.stub().resolves(10);
|
||||
var rejectStub1 = sinon.stub().rejects();
|
||||
var rejectsStub2 = sinon.stub().rejects(new Error('Specified error'));
|
||||
var rejectsStub2 = sinon.stub().rejects("TypeError");
|
||||
}
|
||||
|
||||
function testSymbolMatch() {
|
||||
var stub = sinon.stub();
|
||||
stub(Symbol('TestSymbol'));
|
||||
stub.calledWithMatch(sinon.match.symbol);
|
||||
}
|
||||
|
||||
function testResetHistory() {
|
||||
sinon.stub().resetHistory();
|
||||
}
|
||||
|
||||
testOne();
|
||||
testTwo();
|
||||
testThree();
|
||||
@@ -109,6 +126,9 @@ testSix();
|
||||
testSeven();
|
||||
testEight();
|
||||
testNine();
|
||||
testPromises();
|
||||
testSymbolMatch();
|
||||
testResetHistory();
|
||||
|
||||
var clock = sinon.useFakeTimers();
|
||||
clock.setSystemTime(1000);
|
||||
|
||||
Reference in New Issue
Block a user