Skip to content

Commit

Permalink
Miswrote in keys documentation, corrected mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Dec 2, 2014
1 parent fc276f5 commit 9f67cdf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/chai/core/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -968,16 +968,16 @@ module.exports = function (chai, _) {
* in must exist in the target object. Use without the `any` or `all`
* qualifiers is deprecated and will default to `all`.
*
* Finally, use of `contains` in conjunction with `all` requires that
* the number of passed-in keys match the total number of keys in the target
* object.
* Finally, use of the `all` qualifier in general requires that the number of
* keys passed in must match the number of keys in the target object unless
* the contains qualifier is also used.
*
* expect({ foo: 1, bar: 2 }).to.have.any.keys('foo', 'baz');
* expect({ foo: 1, bar: 2 }).to.have.any.keys('foo');
* expect({ foo: 1, bar: 2 }).to.contain.any.keys('bar', 'baz');
* expect({ foo: 1, bar: 2 }).to.contain.any.keys(['foo']);
* expect({ foo: 1, bar: 2 }).to.have.all.keys(['bar', 'foo']);
* expect({ foo: 1, bar: 2 }).to.contain.all.keys(['bar', 'foo']);
* expect({ foo: 1, bar: 2, baz: 3 }).to.contain.all.keys(['bar', 'foo']);
*
* @name keys
* @alias key
Expand Down
5 changes: 5 additions & 0 deletions test/expect.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ describe('expect', function () {
expect({ foo: 1, bar: 2 }).to.contain.keys(['foo']);
expect({ foo: 1, bar: 2 }).to.contain.keys(['bar']);
expect({ foo: 1, bar: 2 }).to.contain.keys(['bar', 'foo']);
expect({ foo: 1, bar: 2, baz: 3 }).to.contain.all.keys(['bar', 'foo']);

expect({ foo: 1, bar: 2 }).to.not.have.keys('baz');
expect({ foo: 1, bar: 2 }).to.not.have.keys('foo', 'baz');
Expand Down Expand Up @@ -594,6 +595,10 @@ describe('expect', function () {
err(function(){
expect({ foo: 1, bar: 2 }).to.not.have.keys(['foo', 'bar']);
}, "expected { foo: 1, bar: 2 } to not have keys 'foo', and 'bar'");

err(function(){
expect({ foo: 1, bar: 2 }).to.have.all.keys('foo');
}, "expected { foo: 1, bar: 2 } to have key 'foo'");

err(function(){
expect({ foo: 1 }).to.not.contain.keys(['foo']);
Expand Down

0 comments on commit 9f67cdf

Please sign in to comment.