Skip to content

Commit

Permalink
Test that chunked responses are properly toString'ed
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Sep 4, 2011
1 parent 01c4466 commit ab91204
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/server.js
Expand Up @@ -44,3 +44,14 @@ exports.createGetResponse = function (text, contentType) {
}
return l;
}
exports.createChunkResponse = function (chunks, contentType) {
var l = function (req, resp) {
contentType = contentType || 'text/plain'
resp.writeHead(200, {'content-type':contentType})
chunks.forEach(function (chunk) {
resp.write(chunk)
})
resp.end()
}
return l;
}
13 changes: 13 additions & 0 deletions tests/test-body.js
Expand Up @@ -12,6 +12,19 @@ var tests =
{ resp : server.createGetResponse("TESTING!")
, expectBody: "TESTING!"
}
, testGetChunkBreak :
{ resp : server.createChunkResponse(
[ new Buffer([239])
, new Buffer([163])
, new Buffer([191])
, new Buffer([206])
, new Buffer([169])
, new Buffer([226])
, new Buffer([152])
, new Buffer([131])
])
, expectBody: "Ω☃"
}
, testGetJSON :
{ resp : server.createGetResponse('{"test":true}', 'application/json')
, json : true
Expand Down

0 comments on commit ab91204

Please sign in to comment.