Skip to content

Commit

Permalink
fix(lib): [match_body] stringify object by qs package
Browse files Browse the repository at this point in the history
  • Loading branch information
chenghung authored and gr2m committed Nov 24, 2017
1 parent 258ef9c commit e8cb44a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/match_body.js
@@ -1,7 +1,7 @@
'use strict';

var deepEqual = require('deep-equal');
var qs = require('querystring');
var qs = require('qs');

module.exports =
function matchBody(spec, body) {
Expand Down
21 changes: 21 additions & 0 deletions tests/test_body_match.js
Expand Up @@ -88,6 +88,27 @@ test('match body with empty object inside', function (t) {
});
})

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

nock('http://encodingsareus.com')
.post('/', /x/)
.reply(200);

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

test('doesn\'t match body with mismatching keys', function (t) {
nock('http://encodingsareus.com')
.post('/', { a: 'a' })
Expand Down

0 comments on commit e8cb44a

Please sign in to comment.