You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
759 B
36 lines
759 B
'use strict'
|
|
|
|
const t = require('tap')
|
|
const test = t.test
|
|
const FindMyWay = require('../')
|
|
|
|
test('contain param and wildcard together', t => {
|
|
t.plan(4)
|
|
|
|
const findMyWay = FindMyWay({
|
|
defaultRoute: (req, res) => {
|
|
t.fail('we should not be here, the url is: ' + req.url)
|
|
}
|
|
})
|
|
|
|
findMyWay.on('GET', '/:lang/item/:id', (req, res, params) => {
|
|
t.same(params.lang, 'fr')
|
|
t.same(params.id, '12345')
|
|
})
|
|
|
|
findMyWay.on('GET', '/:lang/item/*', (req, res, params) => {
|
|
t.same(params.lang, 'fr')
|
|
t.same(params['*'], '12345/edit')
|
|
})
|
|
|
|
findMyWay.lookup(
|
|
{ method: 'GET', url: '/fr/item/12345', headers: {} },
|
|
null
|
|
)
|
|
|
|
findMyWay.lookup(
|
|
{ method: 'GET', url: '/fr/item/12345/edit', headers: {} },
|
|
null
|
|
)
|
|
})
|