Skip to content

Commit

Permalink
tests: verify all handlers called in stack tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed May 20, 2022
1 parent 7ec5dd2 commit 97f0a51
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions test/Router.js
Expand Up @@ -83,11 +83,20 @@ describe('Router', function(){

var router = new Router()

router.get('/foo', function (req, res, next) {
req.counter = 0
next()
})

for (var i = 0; i < 6000; i++) {
router.get('/foo', function (req, res, next) { next() })
router.get('/foo', function (req, res, next) {
req.counter++
next()
})
}

router.get('/foo', function (req, res) {
assert.strictEqual(req.counter, 6000)
res.end()
})

Expand All @@ -99,11 +108,20 @@ describe('Router', function(){

var router = new Router()

router.use(function (req, res, next) {
req.counter = 0
next()
})

for (var i = 0; i < 6000; i++) {
router.use(function (req, res, next) { next() })
router.use(function (req, res, next) {
req.counter++
next()
})
}

router.use(function (req, res) {
assert.strictEqual(req.counter, 6000)
res.end()
})

Expand Down

0 comments on commit 97f0a51

Please sign in to comment.