Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #258, handles undefined Response object rather than throwing an… #260

Merged
merged 3 commits into from
Sep 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,3 @@ function error(msg, expected, actual) {
err.showDiff = true;
return err;
}

42 changes: 41 additions & 1 deletion test/supertest.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,46 @@ describe('request(app)', function(){
done();
});
});

it('should handle an undefined Response', function (done) {
var app = express();

app.get('/', function(req, res){
setTimeout( function () {
res.end();
}, 20);
});

var s = app.listen(function(){
var url = 'http://localhost:' + s.address().port;
request(url)
.get('/')
.timeout(1)
.expect(200, function (err) {
err.should.be.an.instanceof(Error);
return done();
});
});
});

it('should handle error returned when server goes down', function (done) {
var app = express();

app.get('/', function(req, res){
res.end();
});

var s = app.listen(function(){
var url = 'http://localhost:' + s.address().port;
s.close();
request(url)
.get('/')
.expect(200, function (err) {
err.should.be.an.instanceof(Error);
return done();
});
});
});
});

describe('.expect(status[, fn])', function(){
Expand Down Expand Up @@ -988,4 +1028,4 @@ describe("request.get(url).query(vals) works as expected", function(){
done();
});
});
});
});