Aktueller Stand
This commit is contained in:
65
backend/node_modules/find-my-way/test/find-route.test.js
generated
vendored
65
backend/node_modules/find-my-way/test/find-route.test.js
generated
vendored
@@ -1,21 +1,20 @@
|
||||
'use strict'
|
||||
|
||||
const t = require('tap')
|
||||
const test = t.test
|
||||
const { test } = require('node:test')
|
||||
const rfdc = require('rfdc')({ proto: true })
|
||||
const FindMyWay = require('..')
|
||||
|
||||
function equalRouters (t, router1, router2) {
|
||||
t.strictSame(router1._opts, router2._opts)
|
||||
t.same(router1.routes, router2.routes)
|
||||
t.same(router1.trees, router2.trees)
|
||||
t.assert.deepStrictEqual(router1._opts, router2._opts)
|
||||
t.assert.deepEqual(router1.routes, router2.routes)
|
||||
t.assert.deepEqual(JSON.stringify(router1.trees), JSON.stringify(router2.trees))
|
||||
|
||||
t.strictSame(router1.constrainer.strategies, router2.constrainer.strategies)
|
||||
t.strictSame(
|
||||
t.assert.deepStrictEqual(router1.constrainer.strategies, router2.constrainer.strategies)
|
||||
t.assert.deepStrictEqual(
|
||||
router1.constrainer.strategiesInUse,
|
||||
router2.constrainer.strategiesInUse
|
||||
)
|
||||
t.strictSame(
|
||||
t.assert.deepStrictEqual(
|
||||
router1.constrainer.asyncStrategiesInUse,
|
||||
router2.constrainer.asyncStrategiesInUse
|
||||
)
|
||||
@@ -28,7 +27,7 @@ test('findRoute returns null if there is no routes', (t) => {
|
||||
const fundMyWayClone = rfdc(findMyWay)
|
||||
|
||||
const route = findMyWay.findRoute('GET', '/example')
|
||||
t.equal(route, null)
|
||||
t.assert.equal(route, null)
|
||||
|
||||
equalRouters(t, findMyWay, fundMyWayClone)
|
||||
})
|
||||
@@ -45,9 +44,9 @@ test('findRoute returns handler and store for a static route', (t) => {
|
||||
const fundMyWayClone = rfdc(findMyWay)
|
||||
|
||||
const route = findMyWay.findRoute('GET', '/example')
|
||||
t.equal(route.handler, handler)
|
||||
t.equal(route.store, store)
|
||||
t.deepEqual(route.params, [])
|
||||
t.assert.equal(route.handler, handler)
|
||||
t.assert.equal(route.store, store)
|
||||
t.assert.deepEqual(route.params, [])
|
||||
|
||||
equalRouters(t, findMyWay, fundMyWayClone)
|
||||
})
|
||||
@@ -63,7 +62,7 @@ test('findRoute returns null for a static route', (t) => {
|
||||
const fundMyWayClone = rfdc(findMyWay)
|
||||
|
||||
const route = findMyWay.findRoute('GET', '/example1')
|
||||
t.equal(route, null)
|
||||
t.assert.equal(route, null)
|
||||
|
||||
equalRouters(t, findMyWay, fundMyWayClone)
|
||||
})
|
||||
@@ -79,8 +78,8 @@ test('findRoute returns handler and params for a parametric route', (t) => {
|
||||
const fundMyWayClone = rfdc(findMyWay)
|
||||
|
||||
const route = findMyWay.findRoute('GET', '/:param')
|
||||
t.equal(route.handler, handler)
|
||||
t.deepEqual(route.params, ['param'])
|
||||
t.assert.equal(route.handler, handler)
|
||||
t.assert.deepEqual(route.params, ['param'])
|
||||
|
||||
equalRouters(t, findMyWay, fundMyWayClone)
|
||||
})
|
||||
@@ -96,7 +95,7 @@ test('findRoute returns null for a parametric route', (t) => {
|
||||
const fundMyWayClone = rfdc(findMyWay)
|
||||
|
||||
const route = findMyWay.findRoute('GET', '/bar/:param')
|
||||
t.equal(route, null)
|
||||
t.assert.equal(route, null)
|
||||
|
||||
equalRouters(t, findMyWay, fundMyWayClone)
|
||||
})
|
||||
@@ -112,8 +111,8 @@ test('findRoute returns handler and params for a parametric route with static su
|
||||
const fundMyWayClone = rfdc(findMyWay)
|
||||
|
||||
const route = findMyWay.findRoute('GET', '/:param-static')
|
||||
t.equal(route.handler, handler)
|
||||
t.deepEqual(route.params, ['param'])
|
||||
t.assert.equal(route.handler, handler)
|
||||
t.assert.deepEqual(route.params, ['param'])
|
||||
|
||||
equalRouters(t, findMyWay, fundMyWayClone)
|
||||
})
|
||||
@@ -127,7 +126,7 @@ test('findRoute returns null for a parametric route with static suffix', (t) =>
|
||||
const fundMyWayClone = rfdc(findMyWay)
|
||||
|
||||
const route = findMyWay.findRoute('GET', '/:param-static2')
|
||||
t.equal(route, null)
|
||||
t.assert.equal(route, null)
|
||||
|
||||
equalRouters(t, findMyWay, fundMyWayClone)
|
||||
})
|
||||
@@ -143,8 +142,8 @@ test('findRoute returns handler and original params even if a param name differe
|
||||
const fundMyWayClone = rfdc(findMyWay)
|
||||
|
||||
const route = findMyWay.findRoute('GET', '/:param2')
|
||||
t.equal(route.handler, handler)
|
||||
t.deepEqual(route.params, ['param1'])
|
||||
t.assert.equal(route.handler, handler)
|
||||
t.assert.deepEqual(route.params, ['param1'])
|
||||
|
||||
equalRouters(t, findMyWay, fundMyWayClone)
|
||||
})
|
||||
@@ -160,8 +159,8 @@ test('findRoute returns handler and params for a multi-parametric route', (t) =>
|
||||
const fundMyWayClone = rfdc(findMyWay)
|
||||
|
||||
const route = findMyWay.findRoute('GET', '/:param1-:param2')
|
||||
t.equal(route.handler, handler)
|
||||
t.deepEqual(route.params, ['param1', 'param2'])
|
||||
t.assert.equal(route.handler, handler)
|
||||
t.assert.deepEqual(route.params, ['param1', 'param2'])
|
||||
|
||||
equalRouters(t, findMyWay, fundMyWayClone)
|
||||
})
|
||||
@@ -175,7 +174,7 @@ test('findRoute returns null for a multi-parametric route', (t) => {
|
||||
const fundMyWayClone = rfdc(findMyWay)
|
||||
|
||||
const route = findMyWay.findRoute('GET', '/foo/:param1-:param2/bar2')
|
||||
t.equal(route, null)
|
||||
t.assert.equal(route, null)
|
||||
|
||||
equalRouters(t, findMyWay, fundMyWayClone)
|
||||
})
|
||||
@@ -191,8 +190,8 @@ test('findRoute returns handler and regexp param for a regexp route', (t) => {
|
||||
const fundMyWayClone = rfdc(findMyWay)
|
||||
|
||||
const route = findMyWay.findRoute('GET', '/:param(^\\d+$)')
|
||||
t.equal(route.handler, handler)
|
||||
t.deepEqual(route.params, ['param'])
|
||||
t.assert.equal(route.handler, handler)
|
||||
t.assert.deepEqual(route.params, ['param'])
|
||||
|
||||
equalRouters(t, findMyWay, fundMyWayClone)
|
||||
})
|
||||
@@ -206,7 +205,7 @@ test('findRoute returns null for a regexp route', (t) => {
|
||||
const fundMyWayClone = rfdc(findMyWay)
|
||||
|
||||
const route = findMyWay.findRoute('GET', '/:file(^\\D+).png')
|
||||
t.equal(route, null)
|
||||
t.assert.equal(route, null)
|
||||
|
||||
equalRouters(t, findMyWay, fundMyWayClone)
|
||||
})
|
||||
@@ -222,8 +221,8 @@ test('findRoute returns handler and wildcard param for a wildcard route', (t) =>
|
||||
const fundMyWayClone = rfdc(findMyWay)
|
||||
|
||||
const route = findMyWay.findRoute('GET', '/example/*')
|
||||
t.equal(route.handler, handler)
|
||||
t.deepEqual(route.params, ['*'])
|
||||
t.assert.equal(route.handler, handler)
|
||||
t.assert.deepEqual(route.params, ['*'])
|
||||
|
||||
equalRouters(t, findMyWay, fundMyWayClone)
|
||||
})
|
||||
@@ -237,7 +236,7 @@ test('findRoute returns null for a wildcard route', (t) => {
|
||||
const fundMyWayClone = rfdc(findMyWay)
|
||||
|
||||
const route = findMyWay.findRoute('GET', '/foo2/*')
|
||||
t.equal(route, null)
|
||||
t.assert.equal(route, null)
|
||||
|
||||
equalRouters(t, findMyWay, fundMyWayClone)
|
||||
})
|
||||
@@ -259,17 +258,17 @@ test('findRoute returns handler for a constrained route', (t) => {
|
||||
|
||||
{
|
||||
const route = findMyWay.findRoute('GET', '/example')
|
||||
t.equal(route, null)
|
||||
t.assert.equal(route, null)
|
||||
}
|
||||
|
||||
{
|
||||
const route = findMyWay.findRoute('GET', '/example', { version: '1.0.0' })
|
||||
t.equal(route.handler, handler)
|
||||
t.assert.equal(route.handler, handler)
|
||||
}
|
||||
|
||||
{
|
||||
const route = findMyWay.findRoute('GET', '/example', { version: '2.0.0' })
|
||||
t.equal(route, null)
|
||||
t.assert.equal(route, null)
|
||||
}
|
||||
|
||||
equalRouters(t, findMyWay, fundMyWayClone)
|
||||
|
||||
Reference in New Issue
Block a user