Re-adding chai-as-promised (prior commit contained no content)

This commit is contained in:
Jason Tremper
2014-12-16 15:48:01 -05:00
parent 6ded05375f
commit 7ba61efdb7
2 changed files with 57 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
/// <reference path="../chai/chai.d.ts" />
/// <reference path="chai-as-promised.d.ts" />
import chai = require('chai');
import chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
var promise: any;
chai.expect(promise).to.eventually.equal(3);
chai.expect(promise).to.become(3);
chai.expect(promise).to.be.rejected;
chai.expect(promise).to.be.rejectedWith(Error);
chai.expect(promise).to.notify(() => console.log('done'));
chai.assert.eventually.equal(promise, 4, 'Message');
chai.assert.isFulfilled(promise, "optional message");
chai.assert.becomes(promise, "foo", "optional message");
chai.assert.doesNotBecome(promise, "foo", "optional message");
chai.assert.isRejected(promise, "optional message");
chai.assert.isRejected(promise, Error, "optional message");
chai.assert.isRejected(promise, /error message matcher/, "optional message");

View File

@@ -0,0 +1,35 @@
// Type definitions for chai-as-promised
// Project: https://github.com/domenic/chai-as-promised/
// Definitions by: jt000 <https://github.com/jt000>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../chai/chai.d.ts" />
declare module 'chai-as-promised' {
import chai = require('chai');
function chaiAsPromised(chai: any, utils: any): void;
export = chaiAsPromised;
}
declare module chai {
interface LanguageChains {
become(expected: any): Expect;
eventually: Expect;
rejected: Expect;
rejectedWith(expected: any): Expect;
notify(fn: Function): Expect;
}
interface Assert {
eventually: Assert;
isFulfilled(promise: any, message?: string): void;
becomes(promise: any, expected: any, message?: string): void;
doesNotBecome(promise: any, expected: any, message?: string): void;
isRejected(promise: any, message?: string): void;
isRejected(promise: any, expected: any, message?: string): void;
isRejected(promise: any, match: RegExp, message?: string): void;
}
}