Permalink
Browse files

Added test for double next.

  • Loading branch information...
1 parent 0f3e362 commit e1afe272b5cf6d74edf5e518c92de8211bc6aa80 @rauchg rauchg committed Feb 27, 2012
Showing with 26 additions and 0 deletions.
  1. +26 −0 test/distribute.js
View
@@ -289,4 +289,30 @@ describe('distribute', function () {
}
});
+ it('should not break on double next', function (done) {
+ var httpServer = http.createServer()
+ , srv = distribute(httpServer)
+
+ srv.use(function (req, res, next) {
+ next();
+ setTimeout(function () {
+ expect(next).to.throwException(/more than once.*tobi/);
+ }, 10);
+ });
+
+ srv.use(function (req, res, next) {
+ setTimeout(function () {
+ res.writeHead(200);
+ res.end('Hello World');
+ }, 50);
+ });
+
+ httpServer.listen(4000, function () {
+ request.get('http://localhost:4000/tobi').end(function (res) {
+ expect(res.text).to.be('Hello World');
+ httpServer.on('close', done).close();
+ });
+ });
+ });
+
});

0 comments on commit e1afe27

Please sign in to comment.