diff --git a/tests/server.js b/tests/server.js index 5c5585bb3..99d004a30 100644 --- a/tests/server.js +++ b/tests/server.js @@ -94,7 +94,7 @@ exports.createPostValidator = function (text, reqContentType) { assert.ok(~req.headers['content-type'].indexOf(reqContentType)) } resp.writeHead(200, {'content-type':'text/plain'}) - resp.write('OK') + resp.write(r) resp.end() }) } diff --git a/tests/test-body.js b/tests/test-body.js index a49640f87..77b826d46 100644 --- a/tests/test-body.js +++ b/tests/test-body.js @@ -20,6 +20,8 @@ function addTest(name, data) { t.equal(err, null) if (data.expectBody && Buffer.isBuffer(data.expectBody)) { t.deepEqual(data.expectBody.toString(), body.toString()) + } else if (data.expectBody) { + t.deepEqual(data.expectBody, body) } t.end() }) diff --git a/tests/test-pipes.js b/tests/test-pipes.js index 0e4be002c..140c96c4d 100644 --- a/tests/test-pipes.js +++ b/tests/test-pipes.js @@ -80,7 +80,7 @@ tape('piping to a request object', function(t) { }, function(err, res, body) { t.equal(err, null) t.equal(res.statusCode, 200) - t.equal(body, 'OK') + t.equal(body, 'mydata') t.end() }) mydata.pipe(r1) @@ -90,8 +90,9 @@ tape('piping to a request object', function(t) { }) tape('piping to a request object with a json body', function(t) { - s.once('/push-json', server.createPostValidator('{"foo":"bar"}', 'application/json')) - + var obj = {foo: 'bar'} + var json = JSON.stringify(obj) + s.once('/push-json', server.createPostValidator(json, 'application/json')) var mybodydata = new stream.Stream() mybodydata.readable = true @@ -101,7 +102,7 @@ tape('piping to a request object with a json body', function(t) { }, function(err, res, body) { t.equal(err, null) t.equal(res.statusCode, 200) - t.equal(body, 'OK') + t.deepEqual(body, obj) t.end() }) mybodydata.pipe(r2)