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,11 +1,10 @@
'use strict'
const t = require('tap')
const { Readable } = require('stream')
const test = t.test
const { test } = require('node:test')
const { Readable } = require('node:stream')
const Fastify = require('..')
test('code should handle null/undefined/float', t => {
test('code should handle null/undefined/float', (t, done) => {
t.plan(8)
const fastify = Fastify()
@@ -26,9 +25,9 @@ test('code should handle null/undefined/float', t => {
method: 'GET',
url: '/null'
}, (error, res) => {
t.error(error)
t.equal(res.statusCode, 500)
t.same(res.json(), {
t.assert.ifError(error)
t.assert.strictEqual(res.statusCode, 500)
t.assert.deepStrictEqual(res.json(), {
statusCode: 500,
code: 'FST_ERR_BAD_STATUS_CODE',
error: 'Internal Server Error',
@@ -40,9 +39,9 @@ test('code should handle null/undefined/float', t => {
method: 'GET',
url: '/undefined'
}, (error, res) => {
t.error(error)
t.equal(res.statusCode, 500)
t.same(res.json(), {
t.assert.ifError(error)
t.assert.strictEqual(res.statusCode, 500)
t.assert.deepStrictEqual(res.json(), {
statusCode: 500,
code: 'FST_ERR_BAD_STATUS_CODE',
error: 'Internal Server Error',
@@ -54,12 +53,13 @@ test('code should handle null/undefined/float', t => {
method: 'GET',
url: '/404.5'
}, (error, res) => {
t.error(error)
t.equal(res.statusCode, 404)
t.assert.ifError(error)
t.assert.strictEqual(res.statusCode, 404)
done()
})
})
test('code should handle 204', t => {
test('code should handle 204', (t, done) => {
t.plan(13)
const fastify = Fastify()
@@ -80,7 +80,7 @@ test('code should handle 204', t => {
}
})
stream.on('end', () => {
t.pass('stream ended')
t.assert.ok('stream ended')
})
reply.status(204).send(stream)
})
@@ -89,34 +89,35 @@ test('code should handle 204', t => {
method: 'GET',
url: '/204'
}, (error, res) => {
t.error(error)
t.equal(res.statusCode, 204)
t.equal(res.payload, '')
t.equal(res.headers['content-length'], undefined)
t.assert.ifError(error)
t.assert.strictEqual(res.statusCode, 204)
t.assert.strictEqual(res.payload, '')
t.assert.strictEqual(res.headers['content-length'], undefined)
})
fastify.inject({
method: 'GET',
url: '/undefined/204'
}, (error, res) => {
t.error(error)
t.equal(res.statusCode, 204)
t.equal(res.payload, '')
t.equal(res.headers['content-length'], undefined)
t.assert.ifError(error)
t.assert.strictEqual(res.statusCode, 204)
t.assert.strictEqual(res.payload, '')
t.assert.strictEqual(res.headers['content-length'], undefined)
})
fastify.inject({
method: 'GET',
url: '/stream/204'
}, (error, res) => {
t.error(error)
t.equal(res.statusCode, 204)
t.equal(res.payload, '')
t.equal(res.headers['content-length'], undefined)
t.assert.ifError(error)
t.assert.strictEqual(res.statusCode, 204)
t.assert.strictEqual(res.payload, '')
t.assert.strictEqual(res.headers['content-length'], undefined)
done()
})
})
test('code should handle onSend hook on 204', t => {
test('code should handle onSend hook on 204', (t, done) => {
t.plan(5)
const fastify = Fastify()
@@ -137,10 +138,11 @@ test('code should handle onSend hook on 204', t => {
method: 'GET',
url: '/204'
}, (error, res) => {
t.error(error)
t.equal(res.statusCode, 204)
t.equal(res.payload, '')
t.equal(res.headers['content-length'], undefined)
t.equal(res.headers['content-type'], undefined)
t.assert.ifError(error)
t.assert.strictEqual(res.statusCode, 204)
t.assert.strictEqual(res.payload, '')
t.assert.strictEqual(res.headers['content-length'], undefined)
t.assert.strictEqual(res.headers['content-type'], undefined)
done()
})
})