Aktueller Stand

This commit is contained in:
2026-01-22 19:05:45 +01:00
parent 85dee61a4d
commit e280e4eadb
1967 changed files with 397327 additions and 74093 deletions

View File

@@ -1,17 +1,16 @@
'use strict'
const t = require('tap')
const test = t.test
const { test } = require('node:test')
const FindMyWay = require('..')
test('double colon is replaced with single colon, no parameters', t => {
t.plan(1)
const findMyWay = FindMyWay({
defaultRoute: () => t.fail('should not be default route')
defaultRoute: () => t.assert.fail('should not be default route')
})
function handler (req, res, params) {
t.same(params, {})
t.assert.deepEqual(params, {})
}
findMyWay.on('GET', '/name::customVerb', handler)
@@ -26,22 +25,22 @@ test('exactly one match for static route with colon', t => {
function handler () {}
findMyWay.on('GET', '/name::customVerb', handler)
t.equal(findMyWay.find('GET', '/name:customVerb').handler, handler)
t.equal(findMyWay.find('GET', '/name:test'), null)
t.assert.equal(findMyWay.find('GET', '/name:customVerb').handler, handler)
t.assert.equal(findMyWay.find('GET', '/name:test'), null)
})
test('double colon is replaced with single colon, no parameters, same parent node name', t => {
t.plan(1)
const findMyWay = FindMyWay({
defaultRoute: () => t.fail('should not be default route')
defaultRoute: () => t.assert.fail('should not be default route')
})
findMyWay.on('GET', '/name', () => {
t.fail('should not be parent route')
t.assert.fail('should not be parent route')
})
findMyWay.on('GET', '/name::customVerb', (req, res, params) => {
t.same(params, {})
t.assert.deepEqual(params, {})
})
findMyWay.lookup({ method: 'GET', url: '/name:customVerb', headers: {} }, null)
@@ -50,15 +49,15 @@ test('double colon is replaced with single colon, no parameters, same parent nod
test('double colon is replaced with single colon, default route, same parent node name', t => {
t.plan(1)
const findMyWay = FindMyWay({
defaultRoute: () => t.ok('should be default route')
defaultRoute: () => t.assert.ok('should be default route')
})
findMyWay.on('GET', '/name', () => {
t.fail('should not be parent route')
t.assert.fail('should not be parent route')
})
findMyWay.on('GET', '/name::customVerb', () => {
t.fail('should not be child route')
t.assert.fail('should not be child route')
})
findMyWay.lookup({ method: 'GET', url: '/name:wrongCustomVerb', headers: {} }, null)
@@ -67,11 +66,11 @@ test('double colon is replaced with single colon, default route, same parent nod
test('double colon is replaced with single colon, with parameters', t => {
t.plan(1)
const findMyWay = FindMyWay({
defaultRoute: () => t.fail('should not be default route')
defaultRoute: () => t.assert.fail('should not be default route')
})
findMyWay.on('GET', '/name1::customVerb1/:param1/name2::customVerb2:param2', (req, res, params) => {
t.same(params, {
t.assert.deepEqual(params, {
param1: 'value1',
param2: 'value2'
})