Permalink
Browse files

add test for setting timeout via defaults

  • Loading branch information...
David Radcliffe
David Radcliffe committed Jan 10, 2012
1 parent e547d58 commit 662d6e965efeed8d9a9a6c673ca0e4d89c411883
Showing with 11 additions and 1 deletion.
  1. +11 −1 tests/test-timeout.js
View
@@ -7,7 +7,7 @@ var server = require('./server')
var s = server.createServer();
var expectedBody = "waited";
-var remainingTests = 5;
+var remainingTests = 6;
s.listen(s.port, function () {
// Request that waits for 200ms
@@ -77,6 +77,16 @@ s.listen(s.port, function () {
checkDone();
})
+ // Set timeout via defaults
+ var o = {
+ url: s.url + "/timeout"
+ }
+ var r = request.defaults({timeout: 50});
+ r(o, function (err, resp, body) {
+ assert.equal(err.code, "ETIMEDOUT");
+ checkDone();
+ })
+
function checkDone() {
if(--remainingTests == 0) {
s.close();

0 comments on commit 662d6e9

Please sign in to comment.