Skip to content

Commit

Permalink
added test and little docs
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed May 27, 2020
1 parent d3af9e9 commit e609cdd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,9 @@ Router.prototype.process_params = function process_params(layer, called, req, re
}

/**
* Remove all paths from the current stack
* Removes all paths from the current stack
*
* Removing routes could be useful when you need to add/remove routes on runtime.
*
* @public
*/
Expand Down
15 changes: 15 additions & 0 deletions test/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ describe('Router', function () {
router({}, {}, done)
})

describe('.removeAllRoutes()', function () {
it('should remove all routes from the stack', function (done) {
var router = new Router()

for (var i = 0; i < 10; i++) {
router.get('/thing' + i, helloWorld)
}

router.removeAllRoutes()

assert.equal(router.stack.length, 0)
done()
})
})

describe('.all(path, fn)', function () {
it('should be chainable', function () {
var router = new Router()
Expand Down

0 comments on commit e609cdd

Please sign in to comment.