Skip to content

Commit

Permalink
Merge pull request #456 from chaijs/3.x.x
Browse files Browse the repository at this point in the history
3.x.x
  • Loading branch information
keithamus committed May 29, 2015
2 parents 57a5bfd + 81b88f8 commit 66e6bb6
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 54 deletions.
8 changes: 7 additions & 1 deletion lib/chai/core/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ module.exports = function (chai, _) {
* expect({ foo: 'bar' }).to.be.an('object');
* expect(null).to.be.a('null');
* expect(undefined).to.be.an('undefined');
* expect(new Promise).to.be.a('promise');
* expect(new Float32Array()).to.be.a('float32array');
* expect(Symbol()).to.be.a('symbol');
*
* // es6 overrides
* expect({[Symbol.toStringTag]:()=>'foo'}).to.be.a('foo');
*
* // language chain
* expect(foo).to.be.an.instanceof(Foo);
Expand Down Expand Up @@ -1269,7 +1275,7 @@ module.exports = function (chai, _) {
}

// next, check message
var message = 'object' === _.type(err) && "message" in err
var message = 'error' === _.type(err) && "message" in err
? err.message
: '' + err;

Expand Down
19 changes: 16 additions & 3 deletions lib/chai/interface/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -1243,11 +1243,24 @@ module.exports = function (chai, util) {
}

/*!
* Undocumented / untested
* ### .ifError(object)
*
* Asserts if value is not a false value, and throws if it is a true value.
* This is added to allow for chai to be a drop-in replacement for Node's
* assert class.
*
* var err = new Error('I am a custom error');
* assert.ifError(err); // Rethrows err!
*
* @name ifError
* @param {Object} object
* @api public
*/

assert.ifError = function (val, msg) {
new Assertion(val, msg).to.not.be.ok;
assert.ifError = function (val) {
if (val) {
throw(val);
}
};

/*!
Expand Down
2 changes: 1 addition & 1 deletion lib/chai/utils/hasProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* MIT Licensed
*/

var type = require('./type');
var type = require('type-detect');

/**
* ### .hasProperty(object, name)
Expand Down
2 changes: 1 addition & 1 deletion lib/chai/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exports.test = require('./test');
* type utility
*/

exports.type = require('./type');
exports.type = require('type-detect');

/*!
* message utility
Expand Down
45 changes: 0 additions & 45 deletions lib/chai/utils/type.js

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
},
"dependencies": {
"assertion-error": "1.0.1",
"deep-eql": "0.1.3"
"deep-eql": "0.1.3",
"type-detect": "1.0.0"
},
"devDependencies": {
"browserify": "10.2.1",
Expand Down
5 changes: 3 additions & 2 deletions test/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,9 @@ describe('assert', function () {
assert.ifError(undefined);

err(function () {
assert.ifError('foo');
}, "expected \'foo\' to be falsy");
var err = new Error('This is an error message');
assert.ifError(err);
}, 'This is an error message');
});

it('operator', function() {
Expand Down

0 comments on commit 66e6bb6

Please sign in to comment.