Skip to content

Commit

Permalink
Merge pull request #1570 from seanstrom/support/fix-testbody-tests
Browse files Browse the repository at this point in the history
Discovered tests that weren't properly running
  • Loading branch information
simov committed May 13, 2015
2 parents 880d9a0 + 8a478f0 commit 1c6c132
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/server.js
Expand Up @@ -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()
})
}
Expand Down
2 changes: 2 additions & 0 deletions tests/test-body.js
Expand Up @@ -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()
})
Expand Down
9 changes: 5 additions & 4 deletions tests/test-pipes.js
Expand Up @@ -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)
Expand All @@ -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

Expand All @@ -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)
Expand Down

0 comments on commit 1c6c132

Please sign in to comment.