Skip to content

Commit

Permalink
fix indexing into array with deep propery
Browse files Browse the repository at this point in the history
* added unit test to expect with code from documentation
* added default to res in _getPathValue
  • Loading branch information
Matt committed Mar 2, 2015
1 parent 062d731 commit 396730c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/chai/utils/getPathInfo.js
Expand Up @@ -89,7 +89,7 @@ function parsePath (path) {

function _getPathValue (parsed, obj, index) {
var tmp = obj
, res;
, res = obj;

index = (index === undefined ? parsed.length : index);

Expand Down
6 changes: 6 additions & 0 deletions test/expect.js
Expand Up @@ -446,6 +446,12 @@ describe('expect', function () {
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');

expect(deepObj).to.have.property('teas')
.that.is.an('array')
.with.deep.property('[2]')
.that.deep.equals({tea: 'konacha'});

err(function(){
expect(deepObj).to.have.deep.property('teas[3]');
}, "expected { Object (green, teas) } to have a deep property 'teas[3]'");
Expand Down

0 comments on commit 396730c

Please sign in to comment.