Skip to content

Commit

Permalink
Merge pull request #405 from chaijs/deep-escape-doc-tweaks
Browse files Browse the repository at this point in the history
Tweak documentation on `.deep` flag.
  • Loading branch information
keithamus committed Mar 20, 2015
2 parents 32e890e + dc5bb48 commit 1abc384
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/chai/core/assertions.js
Expand Up @@ -75,9 +75,11 @@ module.exports = function (chai, _) {
* expect({ foo: { bar: { baz: 'quux' } } })
* .to.have.deep.property('foo.bar.baz', 'quux');
*
* In the `property` assertion, setting `deep` flag may require
* to escape dot and brackets, while that is a rare case.
* See also the documentation of `.deep.property`.
* `.deep.property` special characters can be escaped
* by adding two slashes before the `.` or `[]`.
*
* var deepCss = { '.link': { '[target]': 42 }};
* expect(deepCss).to.have.deep.property('\\.link.\\[target\\]', 42);
*
* @name deep
* @api public
Expand Down Expand Up @@ -765,7 +767,7 @@ module.exports = function (chai, _) {
* green: { tea: 'matcha' }
* , teas: [ 'chai', 'matcha', { tea: 'konacha' } ]
* };
*
* expect(deepObj).to.have.deep.property('green.tea', 'matcha');
* expect(deepObj).to.have.deep.property('teas[1]', 'matcha');
* expect(deepObj).to.have.deep.property('teas[2].tea', 'konacha');
Expand Down

0 comments on commit 1abc384

Please sign in to comment.