expand docs to indicate change of subject for chaining. Closes #78

This commit is contained in:
Jake Luer 2012-06-24 09:10:53 -04:00
parent 94cfe27c4c
commit c85882691f

View file

@ -352,6 +352,7 @@ module.exports = function (chai, _) {
*
* @name equal
* @alias eq
* @alias deep.equal
* @param {Mixed} value
* @api public
*/
@ -571,7 +572,6 @@ module.exports = function (chai, _) {
* var obj = { foo: 'bar' };
* expect(obj).to.have.property('foo');
* expect(obj).to.have.property('foo', 'bar');
* expect(obj).to.have.property('foo').to.be.a('string');
*
* // deep referencing
* var deepObj = {
@ -583,7 +583,35 @@ module.exports = function (chai, _) {
* expect(deepObj).to.have.deep.property('teas[1]', 'matcha');
* expect(deepObj).to.have.deep.property('teas[2].tea', 'konacha');
*
* You can also use an array as the starting point of a `deep.property`
* assertion, or traverse nested arrays.
*
* var arr = [
* [ 'chai', 'matcha', 'konacha' ]
* , [ { tea: 'chai' }
* , { tea: 'matcha' }
* , { tea: 'konacha' } ]
* ];
*
* expect(arr).to.have.deep.property('[0][1]', 'matcha');
* expect(arr).to.have.deep.property('[1][2].tea', 'konacha');
*
* Furthermore, `property` changes the subject of the assertion
* to be the value of that property from the original object. This
* permits for further chainable assertions on that property.
*
* expect(obj).to.have.property('foo')
* .that.is.a('string');
* expect(deepObj).to.have.property('green')
* .that.is.an('object')
* .that.deep.equals({ tea: 'matcha' });
* expect(deepObj).to.have.property('teas')
* .that.is.an('array')
* .with.deep.property('[2]')
* .that.deep.equals({ tea: 'konacha' });
*
* @name property
* @alias deep.property
* @param {String} name
* @param {Mixed} value (optional)
* @returns value of property for chaining