Comparing version 3.3.0 to 3.4.0
@@ -124,9 +124,20 @@ # Chai Contribution Guidelines | ||
5. Locally merge (or rebase) the upstream development branch into your topic branch: | ||
5. Run you code to make sure it works. | ||
```bash | ||
npm i | ||
rm chai.js | ||
make chai.js | ||
npm test | ||
# when finished running tests... | ||
git checkout chai.js | ||
``` | ||
6. Locally merge (or rebase) the upstream development branch into your topic branch: | ||
```bash | ||
git pull [--rebase] upstream <dev-branch> | ||
``` | ||
6. Push your topic branch up to your fork: | ||
7. Push your topic branch up to your fork: | ||
@@ -137,3 +148,3 @@ ```bash | ||
7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) with a clear title and description. | ||
8. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) with a clear title and description. | ||
@@ -140,0 +151,0 @@ **IMPORTANT**: By submitting a patch, you agree to allow the project owner to license your work under the same license as that used by the project. |
@@ -14,3 +14,3 @@ /*! | ||
exports.version = '3.3.0'; | ||
exports.version = '3.4.0'; | ||
@@ -17,0 +17,0 @@ /*! |
@@ -139,2 +139,3 @@ /*! | ||
* expect(undefined).to.be.an('undefined'); | ||
* expect(new Error).to.be.an('error'); | ||
* expect(new Promise).to.be.a('promise'); | ||
@@ -199,5 +200,8 @@ * expect(new Float32Array()).to.be.a('float32array'); | ||
function include (val, msg) { | ||
_.expectTypes(this, ['array', 'object', 'string']); | ||
if (msg) flag(this, 'message', msg); | ||
var obj = flag(this, 'object'); | ||
var expected = false; | ||
if (_.type(obj) === 'array' && _.type(val) === 'object') { | ||
@@ -237,3 +241,3 @@ for (var i in obj) { | ||
* | ||
* expect('everthing').to.be.ok; | ||
* expect('everything').to.be.ok; | ||
* expect(1).to.be.ok; | ||
@@ -398,4 +402,13 @@ * expect(false).to.not.be.ok; | ||
Assertion.addProperty('empty', function () { | ||
var obj = flag(this, 'object') | ||
, expected = obj; | ||
if (Array.isArray(obj) || 'string' === typeof object) { | ||
expected = obj.length; | ||
} else if (typeof obj === 'object') { | ||
expected = Object.keys(obj).length; | ||
} | ||
this.assert( | ||
Object.keys(Object(flag(this, 'object'))).length === 0 | ||
!expected | ||
, 'expected #{this} to be empty' | ||
@@ -1250,5 +1263,5 @@ , 'expected #{this} not to be empty' | ||
} else if (typeof constructor === 'function') { | ||
name = constructor.prototype.name || constructor.name; | ||
if (name === 'Error' && constructor !== Error) { | ||
name = (new constructor()).name; | ||
name = constructor.prototype.name; | ||
if (!name || (name === 'Error' && constructor !== Error)) { | ||
name = constructor.name || (new constructor()).name; | ||
} | ||
@@ -1449,2 +1462,3 @@ } else { | ||
* @name closeTo | ||
* @alias approximately | ||
* @param {Number} expected | ||
@@ -1456,3 +1470,3 @@ * @param {Number} delta | ||
Assertion.addMethod('closeTo', function (expected, delta, msg) { | ||
function closeTo(expected, delta, msg) { | ||
if (msg) flag(this, 'message', msg); | ||
@@ -1463,3 +1477,3 @@ var obj = flag(this, 'object'); | ||
if (_.type(expected) !== 'number' || _.type(delta) !== 'number') { | ||
throw new Error('the arguments to closeTo must be numbers'); | ||
throw new Error('the arguments to closeTo or approximately must be numbers'); | ||
} | ||
@@ -1472,4 +1486,7 @@ | ||
); | ||
}); | ||
} | ||
Assertion.addMethod('closeTo', closeTo); | ||
Assertion.addMethod('approximately', closeTo); | ||
function isSubsetOf(subset, superset, cmp) { | ||
@@ -1536,2 +1553,40 @@ return subset.every(function(elem) { | ||
/** | ||
* ### .oneOf(list) | ||
* | ||
* Assert that a value appears somewhere in the top level of array `list`. | ||
* | ||
* expect('a').to.be.oneOf(['a', 'b', 'c']); | ||
* expect(9).to.not.be.oneOf(['z']); | ||
* expect([3]).to.not.be.oneOf([1, 2, [3]]); | ||
* | ||
* var three = [3]; | ||
* // for object-types, contents are not compared | ||
* expect(three).to.not.be.oneOf([1, 2, [3]]); | ||
* // comparing references works | ||
* expect(three).to.be.oneOf([1, 2, three]); | ||
* | ||
* @name oneOf | ||
* @param {Array<*>} list | ||
* @param {String} message _optional_ | ||
* @api public | ||
*/ | ||
function oneOf (list, msg) { | ||
if (msg) flag(this, 'message', msg); | ||
var expected = flag(this, 'object'); | ||
new Assertion(list).to.be.an('array'); | ||
this.assert( | ||
list.indexOf(expected) > -1 | ||
, 'expected #{this} to be one of #{exp}' | ||
, 'expected #{this} to not be one of #{exp}' | ||
, list | ||
, expected | ||
); | ||
} | ||
Assertion.addMethod('oneOf', oneOf); | ||
/** | ||
* ### .change(function) | ||
@@ -1538,0 +1593,0 @@ * |
@@ -1023,3 +1023,3 @@ /*! | ||
* assert.lengthOf([1,2,3], 3, 'array has length of 3'); | ||
* assert.lengthOf('foobar', 5, 'string has length of 6'); | ||
* assert.lengthOf('foobar', 6, 'string has length of 6'); | ||
* | ||
@@ -1171,2 +1171,21 @@ * @name lengthOf | ||
/** | ||
* ### .approximately(actual, expected, delta, [message]) | ||
* | ||
* Asserts that the target is equal `expected`, to within a +/- `delta` range. | ||
* | ||
* assert.approximately(1.5, 1, 0.5, 'numbers are close'); | ||
* | ||
* @name approximately | ||
* @param {Number} actual | ||
* @param {Number} expected | ||
* @param {Number} delta | ||
* @param {String} message | ||
* @api public | ||
*/ | ||
assert.approximately = function (act, exp, delta, msg) { | ||
new Assertion(act, msg).to.be.approximately(exp, delta); | ||
}; | ||
/** | ||
* ### .sameMembers(set1, set2, [message]) | ||
@@ -1228,2 +1247,20 @@ * | ||
/** | ||
* ### .oneOf(inList, list, [message]) | ||
* | ||
* Asserts that non-object, non-array value `inList` appears in the flat array `list`. | ||
* | ||
* assert.oneOf(1, [ 2, 1 ], 'Not found in list'); | ||
* | ||
* @name oneOf | ||
* @param {*} inList | ||
* @param {Array<*>} list | ||
* @param {String} message | ||
* @api public | ||
*/ | ||
assert.oneOf = function (inList, list, msg) { | ||
new Assertion(inList, msg).to.be.oneOf(list); | ||
} | ||
/** | ||
@@ -1230,0 +1267,0 @@ * ### .changes(function, object, property) |
@@ -26,2 +26,7 @@ /*! | ||
/*! | ||
* expectTypes utility | ||
*/ | ||
exports.expectTypes = require('./expectTypes'); | ||
/*! | ||
* message utility | ||
@@ -127,2 +132,1 @@ */ | ||
exports.overwriteChainableMethod = require('./overwriteChainableMethod'); | ||
@@ -20,3 +20,3 @@ { | ||
], | ||
"version": "3.3.0", | ||
"version": "3.4.0", | ||
"repository": { | ||
@@ -23,0 +23,0 @@ "type": "git", |
@@ -52,3 +52,3 @@ [![Chai Documentation](http://chaijs.com/public/img/chai-logo.png)](http://chaijs.com) | ||
Feel free to reach out to any of the core-contributors with you questions or | ||
Feel free to reach out to any of the core contributors with your questions or | ||
concerns. We will do our best to respond in a timely manner. | ||
@@ -55,0 +55,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
374353
40
9915