Skip to content

Commit

Permalink
Actually add attempts test
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Deitte committed Sep 22, 2015
1 parent a130355 commit 0db5402
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/attempts.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict';

var request = require('../');
var t = require('chai').assert;

describe('Request attempts', function () {
it('should show 1 attempt after a successful call', function (done) {
request({
url: 'http://www.filltext.com/?rows=1', // return 1 row of data
}, function (err, response, body) {
t.strictEqual(response.statusCode, 200);
t.strictEqual(response.attempts, 1);
done();
});
});

it('should show 3 attempts after some retries', function (done) {
request({
url: 'http://www.filltext.com/?rows=1&err=500', // return a 500 status
maxAttempts: 3,
retryDelay: 100
}, function (err, response, body) {
t.strictEqual(response.statusCode, 500);
t.strictEqual(response.attempts, 3);
done();
});
});
});

0 comments on commit 0db5402

Please sign in to comment.