Added sinon-chai definition file.

This commit is contained in:
Kazi Manzur Rashid
2013-04-29 23:00:56 +06:00
parent fa81134a20
commit 8b4a498644
2 changed files with 63 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
// Type definitions for sinon-chai expect 2.4.0
// Project: https://github.com/domenic/sinon-chai
// Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid/>
// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../chai/chai.expect.d.ts" />
declare module chai {
interface Been {
called: bool;
calledOnce: bool;
calledTwice: bool;
calledThrice: bool;
calledBefore(spy: any): bool;
calledAfter(spy: any): bool;
calledOn(context: any): bool;
alwaysCalledOn(context: any): bool;
calledWith(...args: any[]): bool;
alwaysCalledWith(...args: any[]): bool;
calledWithExactly(...args: any[]): bool;
alwaysCalledWithExactly(...args: any[]): bool;
calledWithMatch(...args: any[]): bool;
alwaysCalledWithMatch(...args: any[]): bool;
returned(returnVal: any): bool;
alwaysReturned(returnVal: any): bool;
threw(errorObjOrErrorTypeStringOrNothing: any): bool;
alwaysThrew(errorObjOrErrorTypeStringOrNothing: any): bool;
}
interface Have {
been: Been;
}
}
+30
View File
@@ -0,0 +1,30 @@
/// <reference path="../chai/chai.expect.d.ts" />
/// <reference path="sinon-chai.expect.d.ts" />
var expect = chai.expect;
function test() {
var spy;
var anotherSpy;
var context;
var match;
expect(spy).to.have.been.called;
expect(spy).to.have.been.calledOnce;
expect(spy).to.have.been.calledTwice;
expect(spy).to.have.been.calledThrice;
expect(spy).to.have.been.calledBefore(anotherSpy);
expect(spy).to.have.been.calledAfter(anotherSpy);
expect(spy).to.have.been.calledOn(context);
expect(spy).to.have.been.alwaysCalledOn(context);
expect(spy).to.have.been.calledWith('foo', 'bar');
expect(spy).to.have.been.alwaysCalledWith('foo', 'bar');
expect(spy).to.have.been.calledWithExactly('foo', 'bar');
expect(spy).to.have.been.alwaysCalledWithExactly('foo', 'bar');
expect(spy).to.have.been.calledWithMatch(match);
expect(spy).to.have.been.alwaysCalledWithMatch(match);
expect(spy).to.have.been.returned(1);
expect(spy).to.have.been.alwaysReturned(1);
expect(spy).to.have.been.threw('an error');
expect(spy).to.have.been.alwaysThrew('an error');
}