Aktueller Stand
This commit is contained in:
199
backend/node_modules/find-my-way/test/issue-28.test.js
generated
vendored
199
backend/node_modules/find-my-way/test/issue-28.test.js
generated
vendored
@@ -1,30 +1,29 @@
|
||||
'use strict'
|
||||
|
||||
const t = require('tap')
|
||||
const test = t.test
|
||||
const { test } = require('node:test')
|
||||
const FindMyWay = require('../')
|
||||
|
||||
test('wildcard (more complex test)', t => {
|
||||
t.plan(3)
|
||||
const findMyWay = FindMyWay({
|
||||
defaultRoute: (req, res) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
}
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/test/*', (req, res, params) => {
|
||||
switch (params['*']) {
|
||||
case 'hello':
|
||||
t.ok('correct parameter')
|
||||
t.assert.ok('correct parameter')
|
||||
break
|
||||
case 'hello/world':
|
||||
t.ok('correct parameter')
|
||||
t.assert.ok('correct parameter')
|
||||
break
|
||||
case '':
|
||||
t.ok('correct parameter')
|
||||
t.assert.ok('correct parameter')
|
||||
break
|
||||
default:
|
||||
t.fail('wrong parameter: ' + params['*'])
|
||||
t.assert.fail('wrong parameter: ' + params['*'])
|
||||
}
|
||||
})
|
||||
|
||||
@@ -48,16 +47,16 @@ test('Wildcard inside a node with a static route but different method', t => {
|
||||
t.plan(2)
|
||||
const findMyWay = FindMyWay({
|
||||
defaultRoute: (req, res) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
}
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/test/hello', (req, res, params) => {
|
||||
t.equal(req.method, 'GET')
|
||||
t.assert.equal(req.method, 'GET')
|
||||
})
|
||||
|
||||
findMyWay.on('OPTIONS', '/*', (req, res, params) => {
|
||||
t.equal(req.method, 'OPTIONS')
|
||||
t.assert.equal(req.method, 'OPTIONS')
|
||||
})
|
||||
|
||||
findMyWay.lookup(
|
||||
@@ -76,19 +75,19 @@ test('Wildcard inside a node with a static route but different method (more comp
|
||||
const findMyWay = FindMyWay({
|
||||
defaultRoute: (req, res) => {
|
||||
if (req.url === '/test/helloo' && req.method === 'GET') {
|
||||
t.ok('Everything fine')
|
||||
t.assert.ok('Everything fine')
|
||||
} else {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/test/hello', (req, res, params) => {
|
||||
t.equal(req.method, 'GET')
|
||||
t.assert.equal(req.method, 'GET')
|
||||
})
|
||||
|
||||
findMyWay.on('OPTIONS', '/*', (req, res, params) => {
|
||||
t.equal(req.method, 'OPTIONS')
|
||||
t.assert.equal(req.method, 'OPTIONS')
|
||||
})
|
||||
|
||||
findMyWay.lookup(
|
||||
@@ -121,20 +120,20 @@ test('Wildcard edge cases', t => {
|
||||
t.plan(1)
|
||||
const findMyWay = FindMyWay({
|
||||
defaultRoute: (req, res) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
}
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/test1/foo', (req, res, params) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/test2/foo', (req, res, params) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.on('OPTIONS', '/*', (req, res, params) => {
|
||||
t.equal(params['*'], 'test1/foo')
|
||||
t.assert.equal(params['*'], 'test1/foo')
|
||||
})
|
||||
|
||||
findMyWay.lookup(
|
||||
@@ -147,20 +146,20 @@ test('Wildcard edge cases same method', t => {
|
||||
t.plan(2)
|
||||
const findMyWay = FindMyWay({
|
||||
defaultRoute: (req, res) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
}
|
||||
})
|
||||
|
||||
findMyWay.on('OPTIONS', '/test1/foo', (req, res, params) => {
|
||||
t.equal(req.method, 'OPTIONS')
|
||||
t.assert.equal(req.method, 'OPTIONS')
|
||||
})
|
||||
|
||||
findMyWay.on('OPTIONS', '/test2/foo', (req, res, params) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.on('OPTIONS', '/*', (req, res, params) => {
|
||||
t.equal(params['*'], 'test/foo')
|
||||
t.assert.equal(params['*'], 'test/foo')
|
||||
})
|
||||
|
||||
findMyWay.lookup(
|
||||
@@ -178,24 +177,24 @@ test('Wildcard and parametric edge cases', t => {
|
||||
t.plan(3)
|
||||
const findMyWay = FindMyWay({
|
||||
defaultRoute: (req, res) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
}
|
||||
})
|
||||
|
||||
findMyWay.on('OPTIONS', '/test1/foo', (req, res, params) => {
|
||||
t.equal(req.method, 'OPTIONS')
|
||||
t.assert.equal(req.method, 'OPTIONS')
|
||||
})
|
||||
|
||||
findMyWay.on('OPTIONS', '/test2/foo', (req, res, params) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/:test/foo', (req, res, params) => {
|
||||
t.equal(params.test, 'example')
|
||||
t.assert.equal(params.test, 'example')
|
||||
})
|
||||
|
||||
findMyWay.on('OPTIONS', '/*', (req, res, params) => {
|
||||
t.equal(params['*'], 'test/foo/hey')
|
||||
t.assert.equal(params['*'], 'test/foo/hey')
|
||||
})
|
||||
|
||||
findMyWay.lookup(
|
||||
@@ -218,24 +217,24 @@ test('Mixed wildcard and static with same method', t => {
|
||||
t.plan(1)
|
||||
const findMyWay = FindMyWay({
|
||||
defaultRoute: (req, res) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
}
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/foo1/bar1/baz', (req, res, params) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/foo1/bar2/baz', (req, res, params) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/foo2/bar2/baz', (req, res, params) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '*', (req, res, params) => {
|
||||
t.equal(params['*'], '/foo1/bar1/kuux')
|
||||
t.assert.equal(params['*'], '/foo1/bar1/kuux')
|
||||
})
|
||||
|
||||
findMyWay.lookup(
|
||||
@@ -248,20 +247,20 @@ test('Nested wildcards case - 1', t => {
|
||||
t.plan(1)
|
||||
const findMyWay = FindMyWay({
|
||||
defaultRoute: (req, res) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.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)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/foo1/*', (req, res, params) => {
|
||||
t.equal(params['*'], 'bar1/kuux')
|
||||
t.assert.equal(params['*'], 'bar1/kuux')
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/foo2/*', (req, res, params) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.lookup(
|
||||
@@ -274,20 +273,20 @@ test('Nested wildcards case - 2', t => {
|
||||
t.plan(1)
|
||||
const findMyWay = FindMyWay({
|
||||
defaultRoute: (req, res) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.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)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/foo1/*', (req, res, params) => {
|
||||
t.equal(params['*'], 'bar1/kuux')
|
||||
t.assert.equal(params['*'], 'bar1/kuux')
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '*', (req, res, params) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.lookup(
|
||||
@@ -300,28 +299,28 @@ test('Nested wildcards with parametric and static - 1', t => {
|
||||
t.plan(1)
|
||||
const findMyWay = FindMyWay({
|
||||
defaultRoute: (req, res) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.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)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/foo1/*', (req, res, params) => {
|
||||
t.equal(params['*'], 'bar1/kuux')
|
||||
t.assert.equal(params['*'], 'bar1/kuux')
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/foo2/*', (req, res, params) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.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)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/foo4/param', (req, res, params) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.lookup(
|
||||
@@ -334,28 +333,28 @@ test('Nested wildcards with parametric and static - 2', t => {
|
||||
t.plan(1)
|
||||
const findMyWay = FindMyWay({
|
||||
defaultRoute: (req, res) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.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)
|
||||
t.assert.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)
|
||||
t.assert.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)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/foo3/:param', (req, res, params) => {
|
||||
t.equal(params.param, 'bar1')
|
||||
t.assert.equal(params.param, 'bar1')
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/foo4/param', (req, res, params) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.lookup(
|
||||
@@ -368,28 +367,28 @@ test('Nested wildcards with parametric and static - 3', t => {
|
||||
t.plan(1)
|
||||
const findMyWay = FindMyWay({
|
||||
defaultRoute: (req, res) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.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)
|
||||
t.assert.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)
|
||||
t.assert.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)
|
||||
t.assert.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)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/foo4/param', (req, res, params) => {
|
||||
t.equal(req.url, '/foo4/param')
|
||||
t.assert.equal(req.url, '/foo4/param')
|
||||
})
|
||||
|
||||
findMyWay.lookup(
|
||||
@@ -402,28 +401,28 @@ test('Nested wildcards with parametric and static - 4', t => {
|
||||
t.plan(1)
|
||||
const findMyWay = FindMyWay({
|
||||
defaultRoute: (req, res) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.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)
|
||||
t.assert.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)
|
||||
t.assert.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)
|
||||
t.assert.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)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/foo1/param', (req, res, params) => {
|
||||
t.equal(req.url, '/foo1/param')
|
||||
t.assert.equal(req.url, '/foo1/param')
|
||||
})
|
||||
|
||||
findMyWay.lookup(
|
||||
@@ -436,28 +435,28 @@ test('Nested wildcards with parametric and static - 5', t => {
|
||||
t.plan(1)
|
||||
const findMyWay = FindMyWay({
|
||||
defaultRoute: (req, res) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.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)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/foo1/*', (req, res, params) => {
|
||||
t.equal(params['*'], 'param/hello/test/long/routee')
|
||||
t.assert.equal(params['*'], 'param/hello/test/long/routee')
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/foo2/*', (req, res, params) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.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)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/foo1/param/hello/test/long/route', (req, res, params) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.lookup(
|
||||
@@ -470,28 +469,28 @@ test('Nested wildcards with parametric and static - 6', t => {
|
||||
t.plan(1)
|
||||
const findMyWay = FindMyWay({
|
||||
defaultRoute: (req, res) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
}
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '*', (req, res, params) => {
|
||||
t.equal(params['*'], '/foo4/param/hello/test/long/routee')
|
||||
t.assert.equal(params['*'], '/foo4/param/hello/test/long/routee')
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/foo1/*', (req, res, params) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.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)
|
||||
t.assert.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)
|
||||
t.assert.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)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.lookup(
|
||||
@@ -504,32 +503,32 @@ 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)
|
||||
t.assert.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)
|
||||
t.assert.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)
|
||||
t.assert.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)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/foo3/:param', (req, res, params) => {
|
||||
t.equal(params.param, 'hello')
|
||||
t.assert.equal(params.param, 'hello')
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/foo3/*', (req, res, params) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/foo4/example/hello/test/long/route', (req, res, params) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.lookup(
|
||||
@@ -542,32 +541,32 @@ 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)
|
||||
t.assert.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)
|
||||
t.assert.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)
|
||||
t.assert.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)
|
||||
t.assert.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)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/foo3/*', (req, res, params) => {
|
||||
t.equal(params['*'], 'hello/world')
|
||||
t.assert.equal(params['*'], '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)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.lookup(
|
||||
@@ -580,20 +579,20 @@ test('Wildcard node with constraints', t => {
|
||||
t.plan(1)
|
||||
const findMyWay = FindMyWay({
|
||||
defaultRoute: (req, res) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
}
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '*', { constraints: { host: 'fastify.io' } }, (req, res, params) => {
|
||||
t.equal(params['*'], '/foo1/foo3')
|
||||
t.assert.equal(params['*'], '/foo1/foo3')
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/foo1/*', { constraints: { host: 'something-else.io' } }, (req, res, params) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.on('GET', '/foo1/foo2', (req, res, params) => {
|
||||
t.fail('we should not be here, the url is: ' + req.url)
|
||||
t.assert.fail('we should not be here, the url is: ' + req.url)
|
||||
})
|
||||
|
||||
findMyWay.lookup(
|
||||
@@ -609,11 +608,11 @@ test('Wildcard must be the last character in the route', (t) => {
|
||||
|
||||
const findMyWay = FindMyWay()
|
||||
|
||||
t.throws(() => findMyWay.on('GET', '*1', () => {}), expectedError)
|
||||
t.throws(() => findMyWay.on('GET', '*/', () => {}), expectedError)
|
||||
t.throws(() => findMyWay.on('GET', '*?', () => {}), expectedError)
|
||||
t.assert.throws(() => findMyWay.on('GET', '*1', () => {}), expectedError)
|
||||
t.assert.throws(() => findMyWay.on('GET', '*/', () => {}), expectedError)
|
||||
t.assert.throws(() => findMyWay.on('GET', '*?', () => {}), expectedError)
|
||||
|
||||
t.throws(() => findMyWay.on('GET', '/foo*123', () => {}), expectedError)
|
||||
t.throws(() => findMyWay.on('GET', '/foo*?', () => {}), expectedError)
|
||||
t.throws(() => findMyWay.on('GET', '/foo*/', () => {}), expectedError)
|
||||
t.assert.throws(() => findMyWay.on('GET', '/foo*123', () => {}), expectedError)
|
||||
t.assert.throws(() => findMyWay.on('GET', '/foo*?', () => {}), expectedError)
|
||||
t.assert.throws(() => findMyWay.on('GET', '/foo*/', () => {}), expectedError)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user