mirror of
https://github.com/chaijs/chai
synced 2024-11-15 08:17:14 +00:00
expand docs to indicate change of subject for chaining. Closes #78
This commit is contained in:
parent
94cfe27c4c
commit
c85882691f
1 changed files with 29 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue