Skip to content

Commit

Permalink
prev.params should always exist (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
timwis authored Aug 23, 2016
1 parent cdabe22 commit e44f961
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function choo (opts) {
// create a new router with a custom `createRoute()` function
// (str?, obj, fn?) -> null
function createRouter (defaultRoute, routes, createSend) {
var prev = {}
var prev = { params: {} }
return sheetRouter(defaultRoute, routes, createRoute)

function createRoute (routeFn) {
Expand Down
17 changes: 17 additions & 0 deletions tests/browser/routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,21 @@ test('routing', function (t) {

app.start()
})

t.test('prev.params always exists', function (t) {
t.plan(1)

const choo = require('../..')
const app = choo()

app.router('/users/123', (route) => [
route('/users', [
route('/:user', function (state, prev) {
t.ok(prev.params)
})
])
])

app.start()
})
})

0 comments on commit e44f961

Please sign in to comment.