Loading test/request-test.js +21 −6 Original line number Diff line number Diff line Loading @@ -16,9 +16,15 @@ describe('Request-Promise', function () { var path = url.parse(request.url).pathname; var status = parseInt(path.split('/')[1]); if(isNaN(status)) { status = 555; } if (status === 302) { response.writeHead(status, { location: '/200' }); lastResponseBody = ''; response.end(); } else { response.writeHead(status); lastResponseBody = request.method + ' ' + request.url; response.end(lastResponseBody); } }); server.listen(4000, function () { done(); Loading Loading @@ -570,19 +576,19 @@ describe('Request-Promise', function () { describe("should not alter Request's original behavior", function () { it('like emitting errors with no listener', function () { it('for emitting errors with no listener', function () { expect(function () { rp({}); }).to.throw(); }); it('like emitting errors to the callback', function (done) { it('for emitting errors to the callback', function (done) { rp({}, function (err) { if (err) { done(); } }); }); it('like registering to the emitted complete event', function (done) { it('for registering to the emitted complete event', function (done) { rp('http://localhost:4000/200') .on('complete', function (httpResponse, body) { expect(httpResponse.statusCode).to.eql(200); Loading @@ -591,6 +597,15 @@ describe('Request-Promise', function () { }); }); it('for requests with a redirect', function () { return rp('http://localhost:4000/302') .then(function (body) { expect(body).to.eql('GET /200'); }); }); }); }); Loading
test/request-test.js +21 −6 Original line number Diff line number Diff line Loading @@ -16,9 +16,15 @@ describe('Request-Promise', function () { var path = url.parse(request.url).pathname; var status = parseInt(path.split('/')[1]); if(isNaN(status)) { status = 555; } if (status === 302) { response.writeHead(status, { location: '/200' }); lastResponseBody = ''; response.end(); } else { response.writeHead(status); lastResponseBody = request.method + ' ' + request.url; response.end(lastResponseBody); } }); server.listen(4000, function () { done(); Loading Loading @@ -570,19 +576,19 @@ describe('Request-Promise', function () { describe("should not alter Request's original behavior", function () { it('like emitting errors with no listener', function () { it('for emitting errors with no listener', function () { expect(function () { rp({}); }).to.throw(); }); it('like emitting errors to the callback', function (done) { it('for emitting errors to the callback', function (done) { rp({}, function (err) { if (err) { done(); } }); }); it('like registering to the emitted complete event', function (done) { it('for registering to the emitted complete event', function (done) { rp('http://localhost:4000/200') .on('complete', function (httpResponse, body) { expect(httpResponse.statusCode).to.eql(200); Loading @@ -591,6 +597,15 @@ describe('Request-Promise', function () { }); }); it('for requests with a redirect', function () { return rp('http://localhost:4000/302') .then(function (body) { expect(body).to.eql('GET /200'); }); }); }); });