diff --git a/lib/chai/utils/getPathInfo.js b/lib/chai/utils/getPathInfo.js index 538b2a1c9..dac2194ad 100644 --- a/lib/chai/utils/getPathInfo.js +++ b/lib/chai/utils/getPathInfo.js @@ -89,7 +89,7 @@ function parsePath (path) { function _getPathValue (parsed, obj, index) { var tmp = obj - , res; + , res = obj; index = (index === undefined ? parsed.length : index); diff --git a/test/expect.js b/test/expect.js index 9db12dee0..cd204a9b0 100644 --- a/test/expect.js +++ b/test/expect.js @@ -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]'");