reply-trailers.test.js — fastify Source File
Architecture documentation for reply-trailers.test.js, a javascript file in the fastify codebase.
Entity Profile
Source Code
'use strict'
const { test, describe } = require('node:test')
const Fastify = require('..')
const { Readable } = require('node:stream')
const { createHash } = require('node:crypto')
const { sleep } = require('./helper')
test('send trailers when payload is empty string', (t, testDone) => {
t.plan(5)
const fastify = Fastify()
fastify.get('/', function (request, reply) {
reply.trailer('ETag', function (reply, payload, done) {
done(null, 'custom-etag')
})
reply.send('')
})
fastify.inject({
method: 'GET',
url: '/'
}, (error, res) => {
t.assert.ifError(error)
t.assert.strictEqual(res.statusCode, 200)
t.assert.strictEqual(res.headers.trailer, 'etag')
t.assert.strictEqual(res.trailers.etag, 'custom-etag')
t.assert.ok(!res.headers['content-length'])
testDone()
})
})
test('send trailers when payload is empty buffer', (t, testDone) => {
t.plan(5)
const fastify = Fastify()
fastify.get('/', function (request, reply) {
reply.trailer('ETag', function (reply, payload, done) {
done(null, 'custom-etag')
})
reply.send(Buffer.alloc(0))
})
fastify.inject({
method: 'GET',
url: '/'
}, (error, res) => {
t.assert.ifError(error)
t.assert.strictEqual(res.statusCode, 200)
t.assert.strictEqual(res.headers.trailer, 'etag')
t.assert.strictEqual(res.trailers.etag, 'custom-etag')
t.assert.ok(!res.headers['content-length'])
testDone()
})
})
test('send trailers when payload is undefined', (t, testDone) => {
t.plan(5)
// ... (386 more lines)
Source
Frequently Asked Questions
What does reply-trailers.test.js do?
reply-trailers.test.js is a source file in the fastify codebase, written in javascript.
Where is reply-trailers.test.js in the architecture?
reply-trailers.test.js is located at test/reply-trailers.test.js (directory: test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free