Skip to content
Myr

tests: flow control with after

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent 98d17e2 · Browse files · 2 files+6 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+6 added−3 removed

  • tests:+5 added−3 removed
  • other:+1 added−0 removed

2 files+6 added−3 removed

modified:test/Router.js+5 added-3 removed
12var after = require('after');3var express = require('../')4 , Router = express.Router5 , methods = require('methods')6 , assert = require('assert');
234 unmodified lines
241 });242243 describe('parallel requests', function() {244 it('should not mix requests', function(done) {244 var count = 2;245 var req1 = { url: '/foo/50/bar', method: 'get' };246 var req2 = { url: '/foo/10/bar', method: 'get' };247 var router = new Router();248 var sub = new Router();249250 done = after(2, done);251252 sub.get('/bar', function(req, res, next) {253 next();254 });255
9 unmodified lines
265 router.handle(req1, {}, function(err) {266 assert.ifError(err);267 assert.equal(req1.ms, 50);268 assert.equal(req1.originalUrl, '/foo/50/bar');267 if (!--count) done();269 done();270 });271272 router.handle(req2, {}, function(err) {273 assert.ifError(err);274 assert.equal(req2.ms, 10);275 assert.equal(req2.originalUrl, '/foo/10/bar');274 if (!--count) done();276 done();277 });278 });279 });280})
modified:package.json+1 added