Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed redirect handling. Includes tests

  • Loading branch information...
commit c0096236bf28d70eda8c5a2b13ae6f160a1ffe41 1 parent 8672459
@ravenac95 authored
Showing with 31 additions and 1 deletion.
  1. +1 −1  lib/test.js
  2. +30 −0 test/supertest.js
View
2  lib/test.js
@@ -120,7 +120,7 @@ Test.prototype.expect = function(a, b, c){
Test.prototype.end = function(fn){
var self = this;
var end = Request.prototype.end;
- end.call(this, function(res){
+ end.call(this, function(err, res){
self.assert(res, fn);
});
return this;
View
30 test/supertest.js
@@ -119,6 +119,36 @@ describe('request(app)', function(){
.expect(302, done);
})
+ it('should redirect many times', function(done){
+ var app = express();
+
+ app.get('/', function(req, res){
+ res.redirect('/redirect1');
+ });
+
+ app.get('/redirect1', function(req, res){
+ res.redirect('/redirect2');
+ });
+
+ app.get('/redirect2', function(req, res){
+ res.redirect('/redirect3');
+ });
+
+ app.get('/redirect3', function(req, res){
+ res.send(200, 'Redirected 3 times');
+ });
+
+ request(app)
+ .get('/')
+ .redirects(5)
+ .end(function(err, res) {
+ res.should.have.status(200);
+ res.redirects.should.have.length(3);
+ res.text.should.equal('Redirected 3 times');
+ done()
+ });
+ })
+
describe('.expect(status[, fn])', function(){
it('should assert the response status', function(done){
var app = express();
Please sign in to comment.
Something went wrong with that request. Please try again.