find-route.test.js — fastify Source File
Architecture documentation for find-route.test.js, a javascript file in the fastify codebase.
Entity Profile
Source Code
'use strict'
const { test } = require('node:test')
const Fastify = require('..')
const fastifyPlugin = require('fastify-plugin')
test('findRoute should return null when route cannot be found due to a different method', t => {
t.plan(1)
const fastify = Fastify()
fastify.get('/artists/:artistId', {
schema: {
params: { artistId: { type: 'integer' } }
},
handler: (req, reply) => reply.send(typeof req.params.artistId)
})
t.assert.strictEqual(fastify.findRoute({
method: 'POST',
url: '/artists/:artistId'
}), null)
})
test('findRoute should return an immutable route to avoid leaking and runtime route modifications', t => {
t.plan(1)
const fastify = Fastify()
fastify.get('/artists/:artistId', {
schema: {
params: { artistId: { type: 'integer' } }
},
handler: (req, reply) => reply.send(typeof req.params.artistId)
})
let route = fastify.findRoute({
method: 'GET',
url: '/artists/:artistId'
})
route.params = {
...route.params,
id: ':id'
}
route = fastify.findRoute({
method: 'GET',
url: '/artists/:artistId'
})
t.assert.strictEqual(route.params.artistId, ':artistId')
})
test('findRoute should return null when when url is not passed', t => {
t.plan(1)
const fastify = Fastify()
fastify.get('/artists/:artistId', {
schema: {
params: { artistId: { type: 'integer' } }
},
// ... (93 more lines)
Source
Frequently Asked Questions
What does find-route.test.js do?
find-route.test.js is a source file in the fastify codebase, written in javascript.
Where is find-route.test.js in the architecture?
find-route.test.js is located at test/find-route.test.js (directory: test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free