Projektstart
This commit is contained in:
28
backend/node_modules/@fastify/send/test/utils.js
generated
vendored
Normal file
28
backend/node_modules/@fastify/send/test/utils.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
'use strict'
|
||||
|
||||
const http = require('http')
|
||||
const send = require('..')
|
||||
|
||||
module.exports.shouldNotHaveHeader = function shouldNotHaveHeader (header, t) {
|
||||
return function (res) {
|
||||
t.ok(!(header.toLowerCase() in res.headers), 'should not have header ' + header)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.createServer = function createServer (opts, fn) {
|
||||
return http.createServer(function onRequest (req, res) {
|
||||
try {
|
||||
fn && fn(req, res)
|
||||
send(req, req.url, opts).pipe(res)
|
||||
} catch (err) {
|
||||
res.statusCode = 500
|
||||
res.end(String(err))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
module.exports.shouldNotHaveBody = function shouldNotHaveBody (t) {
|
||||
return function (res) {
|
||||
t.ok(res.text === '' || res.text === undefined)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user