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,41 +1,40 @@
'use strict'
const t = require('tap')
const test = t.test
const { test } = require('node:test')
const FindMyWay = require('../')
test('If onBadUrl is defined, then a bad url should be handled differently (find)', t => {
t.plan(1)
const findMyWay = FindMyWay({
defaultRoute: (req, res) => {
t.fail('Should not be defaultRoute')
t.assert.fail('Should not be defaultRoute')
},
onBadUrl: (path, req, res) => {
t.equal(path, '/%world', { todo: 'this is not executed' })
t.assert.equal(path, '/%world', { todo: 'this is not executed' })
}
})
findMyWay.on('GET', '/hello/:id', (req, res) => {
t.fail('Should not be here')
t.assert.fail('Should not be here')
})
const handle = findMyWay.find('GET', '/hello/%world')
t.not(handle, null)
t.assert.notDeepStrictEqual(handle, null)
})
test('If onBadUrl is defined, then a bad url should be handled differently (lookup)', t => {
t.plan(1)
const findMyWay = FindMyWay({
defaultRoute: (req, res) => {
t.fail('Should not be defaultRoute')
t.assert.fail('Should not be defaultRoute')
},
onBadUrl: (path, req, res) => {
t.equal(path, '/hello/%world')
t.assert.equal(path, '/hello/%world')
}
})
findMyWay.on('GET', '/hello/:id', (req, res) => {
t.fail('Should not be here')
t.assert.fail('Should not be here')
})
findMyWay.lookup({ method: 'GET', url: '/hello/%world', headers: {} }, null)
@@ -45,28 +44,28 @@ test('If onBadUrl is not defined, then we should call the defaultRoute (find)',
t.plan(1)
const findMyWay = FindMyWay({
defaultRoute: (req, res) => {
t.fail('Should not be defaultRoute')
t.assert.fail('Should not be defaultRoute')
}
})
findMyWay.on('GET', '/hello/:id', (req, res) => {
t.fail('Should not be here')
t.assert.fail('Should not be here')
})
const handle = findMyWay.find('GET', '/hello/%world')
t.equal(handle, null)
t.assert.equal(handle, null)
})
test('If onBadUrl is not defined, then we should call the defaultRoute (lookup)', t => {
t.plan(1)
const findMyWay = FindMyWay({
defaultRoute: (req, res) => {
t.pass('Everything fine')
t.assert.ok('Everything fine')
}
})
findMyWay.on('GET', '/hello/:id', (req, res) => {
t.fail('Should not be here')
t.assert.fail('Should not be here')
})
findMyWay.lookup({ method: 'GET', url: '/hello/%world', headers: {} }, null)