/
erioxis
/
web-nodejs
Обзор
Документация
Войти
/
erioxis
/
web-nodejs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
backend/node_modules/fastify/test/internals/all.test.js
38 строк
853 B
erioxis
lab11fix
15 дек 2025, 23:21
15 дек 2025, 23:21
70dc7ba
Код
Авторство
О чём код?
'use strict' const { test } = require('node:test') const Fastify = require('../..') test('fastify.all should add all the methods to the same url', async t => { const fastify = Fastify() const requirePayload = [ 'POST', 'PUT', 'PATCH' ] const supportedMethods = fastify.supportedMethods t.plan(supportedMethods.length) fastify.all('/', (req, reply) => { reply.send({ method: req.raw.method }) }) await Promise.all(supportedMethods.map(async method => injectRequest(method))) async function injectRequest (method) { const options = { url: '/', method } if (requirePayload.includes(method)) { options.payload = { hello: 'world' } } const res = await fastify.inject(options) const payload = JSON.parse(res.payload) t.assert.deepStrictEqual(payload, { method }) } })