Aktueller Stand
This commit is contained in:
37
backend/node_modules/find-my-way/test/issue-46.test.js
generated
vendored
37
backend/node_modules/find-my-way/test/issue-46.test.js
generated
vendored
@@ -1,29 +1,28 @@
|
||||
'use strict'
|
||||
|
||||
const t = require('tap')
|
||||
const test = t.test
|
||||
const { test } = require('node:test')
|
||||
const FindMyWay = require('../')
|
||||
|
||||
test('If the prefixLen is higher than the pathLen we should not save the wildcard child', t => {
|
||||
t.plan(3)
|
||||
const findMyWay = FindMyWay({
|
||||
defaultRoute: (req, res) => {
|
||||
t.fail('Should not be defaultRoute')
|
||||
t.assert.fail('Should not be defaultRoute')
|
||||
}
|
||||
})
|
||||
|
||||
findMyWay.get('/static/*', () => {})
|
||||
|
||||
t.same(findMyWay.find('GET', '/static/').params, { '*': '' })
|
||||
t.same(findMyWay.find('GET', '/static/hello').params, { '*': 'hello' })
|
||||
t.same(findMyWay.find('GET', '/static'), null)
|
||||
t.assert.deepEqual(findMyWay.find('GET', '/static/').params, { '*': '' })
|
||||
t.assert.deepEqual(findMyWay.find('GET', '/static/hello').params, { '*': 'hello' })
|
||||
t.assert.deepEqual(findMyWay.find('GET', '/static'), null)
|
||||
})
|
||||
|
||||
test('If the prefixLen is higher than the pathLen we should not save the wildcard child (mixed routes)', t => {
|
||||
t.plan(3)
|
||||
const findMyWay = FindMyWay({
|
||||
defaultRoute: (req, res) => {
|
||||
t.fail('Should not be defaultRoute')
|
||||
t.assert.fail('Should not be defaultRoute')
|
||||
}
|
||||
})
|
||||
|
||||
@@ -32,16 +31,16 @@ test('If the prefixLen is higher than the pathLen we should not save the wildcar
|
||||
findMyWay.get('/simple/:bar', () => {})
|
||||
findMyWay.get('/hello', () => {})
|
||||
|
||||
t.same(findMyWay.find('GET', '/static/').params, { '*': '' })
|
||||
t.same(findMyWay.find('GET', '/static/hello').params, { '*': 'hello' })
|
||||
t.same(findMyWay.find('GET', '/static'), null)
|
||||
t.assert.deepEqual(findMyWay.find('GET', '/static/').params, { '*': '' })
|
||||
t.assert.deepEqual(findMyWay.find('GET', '/static/hello').params, { '*': 'hello' })
|
||||
t.assert.deepEqual(findMyWay.find('GET', '/static'), null)
|
||||
})
|
||||
|
||||
test('If the prefixLen is higher than the pathLen we should not save the wildcard child (with a root wildcard)', t => {
|
||||
t.plan(3)
|
||||
const findMyWay = FindMyWay({
|
||||
defaultRoute: (req, res) => {
|
||||
t.fail('Should not be defaultRoute')
|
||||
t.assert.fail('Should not be defaultRoute')
|
||||
}
|
||||
})
|
||||
|
||||
@@ -51,16 +50,16 @@ test('If the prefixLen is higher than the pathLen we should not save the wildcar
|
||||
findMyWay.get('/simple/:bar', () => {})
|
||||
findMyWay.get('/hello', () => {})
|
||||
|
||||
t.same(findMyWay.find('GET', '/static/').params, { '*': '' })
|
||||
t.same(findMyWay.find('GET', '/static/hello').params, { '*': 'hello' })
|
||||
t.same(findMyWay.find('GET', '/static').params, { '*': '/static' })
|
||||
t.assert.deepEqual(findMyWay.find('GET', '/static/').params, { '*': '' })
|
||||
t.assert.deepEqual(findMyWay.find('GET', '/static/hello').params, { '*': 'hello' })
|
||||
t.assert.deepEqual(findMyWay.find('GET', '/static').params, { '*': '/static' })
|
||||
})
|
||||
|
||||
test('If the prefixLen is higher than the pathLen we should not save the wildcard child (404)', t => {
|
||||
t.plan(4)
|
||||
const findMyWay = FindMyWay({
|
||||
defaultRoute: (req, res) => {
|
||||
t.fail('Should not be defaultRoute')
|
||||
t.assert.fail('Should not be defaultRoute')
|
||||
}
|
||||
})
|
||||
|
||||
@@ -69,8 +68,8 @@ test('If the prefixLen is higher than the pathLen we should not save the wildcar
|
||||
findMyWay.get('/simple/:bar', () => {})
|
||||
findMyWay.get('/hello', () => {})
|
||||
|
||||
t.same(findMyWay.find('GET', '/stati'), null)
|
||||
t.same(findMyWay.find('GET', '/staticc'), null)
|
||||
t.same(findMyWay.find('GET', '/stati/hello'), null)
|
||||
t.same(findMyWay.find('GET', '/staticc/hello'), null)
|
||||
t.assert.deepEqual(findMyWay.find('GET', '/stati'), null)
|
||||
t.assert.deepEqual(findMyWay.find('GET', '/staticc'), null)
|
||||
t.assert.deepEqual(findMyWay.find('GET', '/stati/hello'), null)
|
||||
t.assert.deepEqual(findMyWay.find('GET', '/staticc/hello'), null)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user