Skip to content

Commit

Permalink
fix(tests): bring node-request-retry to a 100% code-coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
FGRibreau committed Sep 3, 2016
1 parent e6c2160 commit 6275780
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/api-surface.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ var t = require('chai').assert;

describe('API surface', function () {

describe('request methods', function(){
it('should work with .on', function(f){
request('http://httpbin.org/delay/0.1').on('end', function(){
f();
});
});
});

describe('callback api', function(){
[['request', request], ['request.get', request.get]].forEach(function(pair){
it('should work with '+pair[0]+'(url, f)', function (done) {
Expand Down
14 changes: 14 additions & 0 deletions test/promises.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ describe('Promises support', function () {
});
});

it('should reject the promise on request aborted', function (done) {
var req = request({
url: 'http://www.filltext.com/?rows=1', // return 1 row of data
});

req._req = null;
req.abort();

req.catch(function (err) {
t.strictEqual(err.message, 'Aborted');
done();
});
});

it('should reject the response on any error', function (done) {
request({
url: 'http://localhost:1', // return 1 row of data
Expand Down

0 comments on commit 6275780

Please sign in to comment.