Skip to content

Commit

Permalink
Updated test
Browse files Browse the repository at this point in the history
  • Loading branch information
delvedor committed Oct 8, 2017
1 parent 649f984 commit 70596dd
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions test/issue-28.test.js
Expand Up @@ -499,3 +499,79 @@ test('Nested wildcards with parametric and static - 6', t => {
null
)
})

test('Nested wildcards with parametric and static - 7', t => {
t.plan(1)
const findMyWay = FindMyWay({
defaultRoute: (req, res) => {
t.fail('we should not be here, the url is: ' + req.url)
}
})

findMyWay.on('GET', '*', (req, res, params) => {
t.fail('we should not be here, the url is: ' + req.url)
})

findMyWay.on('GET', '/foo1/*', (req, res, params) => {
t.fail('we should not be here, the url is: ' + req.url)
})

findMyWay.on('GET', '/foo2/*', (req, res, params) => {
t.fail('we should not be here, the url is: ' + req.url)
})

findMyWay.on('GET', '/foo3/:param', (req, res, params) => {
t.is(req.url, '/foo3/hello')
})

findMyWay.on('GET', '/foo3/*', (req, res, params) => {
t.fail('we should not be here, the url is: ' + req.url)
})

findMyWay.on('GET', '/foo4/param/hello/test/long/route', (req, res, params) => {
t.fail('we should not be here, the url is: ' + req.url)
})

findMyWay.lookup(
{ method: 'GET', url: '/foo3/hello' },
null
)
})

test('Nested wildcards with parametric and static - 8', t => {
t.plan(1)
const findMyWay = FindMyWay({
defaultRoute: (req, res) => {
t.fail('we should not be here, the url is: ' + req.url)
}
})

findMyWay.on('GET', '*', (req, res, params) => {
t.fail('we should not be here, the url is: ' + req.url)
})

findMyWay.on('GET', '/foo1/*', (req, res, params) => {
t.fail('we should not be here, the url is: ' + req.url)
})

findMyWay.on('GET', '/foo2/*', (req, res, params) => {
t.fail('we should not be here, the url is: ' + req.url)
})

findMyWay.on('GET', '/foo3/:param', (req, res, params) => {
t.fail('we should not be here, the url is: ' + req.url)
})

findMyWay.on('GET', '/foo3/*', (req, res, params) => {
t.is(req.url, '/foo3/hello/world')
})

findMyWay.on('GET', '/foo4/param/hello/test/long/route', (req, res, params) => {
t.fail('we should not be here, the url is: ' + req.url)
})

findMyWay.lookup(
{ method: 'GET', url: '/foo3/hello/world' },
null
)
})

0 comments on commit 70596dd

Please sign in to comment.