Comparing version 0.13.2 to 0.13.3
@@ -173,14 +173,16 @@ var IncomingMessage = require('http').IncomingMessage; | ||
next.push(function() { | ||
if (encoding) { | ||
if (isStream(responseBody)) { | ||
responseBody.setEncoding(encoding); | ||
} else { | ||
responseBody = responseBody.toString(encoding); | ||
if (typeof responseBody !== "undefined") { | ||
next.push(function() { | ||
if (encoding) { | ||
if (isStream(responseBody)) { | ||
responseBody.setEncoding(encoding); | ||
} else { | ||
responseBody = responseBody.toString(encoding); | ||
} | ||
} | ||
} | ||
if (! isStream(responseBody)) { | ||
response.emit('data', responseBody); | ||
} | ||
}); | ||
if (! isStream(responseBody)) { | ||
response.emit('data', responseBody); | ||
} | ||
}); | ||
} | ||
@@ -187,0 +189,0 @@ if (! isStream(responseBody)) { |
{ "name" : "nock" | ||
, "description" : "HTTP Server mocking for Node.js" | ||
, "tags" : ["Mock", "HTTP", "testing", "isolation"] | ||
, "version" : "0.13.2" | ||
, "version" : "0.13.3" | ||
, "author" : "Pedro Teixeira <pedro.teixeira@gmail.com>" | ||
@@ -6,0 +6,0 @@ , "contributors" : |
@@ -113,7 +113,5 @@ var nock = require('../.') | ||
tap.test("post with empty response body", function(t) { | ||
var dataCalled = false; | ||
var scope = nock('http://www.google.com') | ||
.post('/form') | ||
.reply(201, "OK!"); | ||
.reply(200); | ||
@@ -127,5 +125,4 @@ var req = http.request({ | ||
t.equal(res.statusCode, 201); | ||
t.equal(res.statusCode, 200); | ||
res.on('end', function() { | ||
t.ok(dataCalled); | ||
scope.done(); | ||
@@ -135,5 +132,3 @@ t.end(); | ||
res.on('data', function(data) { | ||
dataCalled = true; | ||
t.ok(data instanceof Buffer, "data should be buffer"); | ||
t.equal(data.toString(), "OK!", "response should match"); | ||
t.fail("No body should be returned") | ||
}); | ||
@@ -140,0 +135,0 @@ |
66309
1914