Merge pull request #405 from chaijs/deep-escape-doc-tweaks

Tweak documentation on `.deep` flag.
This commit is contained in:
Keith Cirkel 2015-03-20 09:46:02 +00:00
commit 1abc3845e3

View file

@ -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
@ -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');