Skip to content

Commit

Permalink
Edited documentation for keys to better match how it interacts with c…
Browse files Browse the repository at this point in the history
…ontains and have
  • Loading branch information
root committed Dec 3, 2014
1 parent f3620c9 commit a0743b0
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/chai/core/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -966,16 +966,22 @@ module.exports = function (chai, _) {
* ### .keys(key1, [key2], [...])
*
* Asserts that the target contains any or all of the passed-in keys.
* When used in conjunction with `all`, every key that is passed in
* must exist in the target object.
* Use in combination with `any`, `all`, `contains`, or `have` will affect
* what will pass.
*
* When used in conjunction with `any`, at least one key that is passed
* in must exist in the target object. Use without the `any` or `all`
* qualifiers is deprecated and will default to `all`.
* in must exist in the target object. This is regardless whether or not
* the `have` or `contain` qualifiers are used. Note, either `any` or `all`
* should be used in the assertion. If neither are used, the assertion is
* defaulted to `all`.
*
* 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.
* When both `all` and `contain` are used, the target object must have at
* least all of the passed-in keys but may have more keys not listed.
*
* When both `all` and `have` are used, the target object must both contain
* all of the passed-in keys AND the number of keys in the target object must
* match the number of keys passed in (in other words, a target object must
* have all and only all of the passed-in keys).
*
* expect({ foo: 1, bar: 2 }).to.have.any.keys('foo', 'baz');
* expect({ foo: 1, bar: 2 }).to.have.any.keys('foo');
Expand Down

0 comments on commit a0743b0

Please sign in to comment.