Skip to content

Commit

Permalink
Merge pull request #734 from RobertWHurst/master
Browse files Browse the repository at this point in the history
Fixes regression introduced by #719
  • Loading branch information
vrinek committed Oct 28, 2016
2 parents 2a1bc2d + a67fe14 commit 15b4d27
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/match_body.js
Expand Up @@ -57,7 +57,7 @@ function deepEqualExtended(spec, body) {
if (spec && spec.constructor === RegExp) {
return spec.test(body);
}
if (spec && spec.constructor === Object || spec.constructor === Array && body) {
if (spec && (spec.constructor === Object || spec.constructor === Array) && body) {
var keys = Object.keys(spec);
for (var i = 0; i < keys.length; i++) {
if (!deepEqualExtended(spec[keys[i]], body[keys[i]])) {
Expand Down
19 changes: 19 additions & 0 deletions tests/test_body_match.js
Expand Up @@ -47,3 +47,22 @@ test('match body with regex inside array', function (t) {
t.end();
});
})

test('match body with empty object inside', function (t) {

nock('http://encodingsareus.com')
.post('/', { obj: {}})
.reply(200);

mikealRequest({
url: 'http://encodingsareus.com/',
method: 'post',
json: {
obj: {}
},
}, function(err, res) {
if (err) throw err;
assert.equal(res.statusCode, 200);
t.end();
});
})

0 comments on commit 15b4d27

Please sign in to comment.