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,59 +1,56 @@
'use strict'
const { test } = require('tap')
const path = require('path')
const { test } = require('node:test')
const path = require('node:path')
const request = require('supertest')
const send = require('..')
const { shouldNotHaveHeader, createServer } = require('./utils')
const fixtures = path.join(__dirname, 'fixtures')
test('send.mime', function (t) {
test('send.mime', async function (t) {
t.plan(2)
t.test('should be exposed', function (t) {
await t.test('should be exposed', function (t) {
t.plan(1)
t.ok(send.mime)
t.assert.ok(send.mime)
})
t.test('.default_type', function (t) {
await t.test('.default_type', async function (t) {
t.plan(3)
t.before(function () {
t.before(() => {
this.default_type = send.mime.default_type
})
t.afterEach(function () {
t.afterEach(() => {
send.mime.default_type = this.default_type
})
t.test('should change the default type', function (t) {
t.plan(1)
await t.test('should change the default type', async function (t) {
send.mime.default_type = 'text/plain'
request(createServer({ root: fixtures }))
await request(createServer({ root: fixtures }))
.get('/no_ext')
.expect('Content-Type', 'text/plain; charset=UTF-8')
.expect(200, err => t.error(err))
.expect('Content-Type', 'text/plain; charset=utf-8')
.expect(200)
})
t.test('should not add Content-Type for undefined default', function (t) {
t.plan(2)
await t.test('should not add Content-Type for undefined default', async function (t) {
t.plan(1)
send.mime.default_type = undefined
request(createServer({ root: fixtures }))
await request(createServer({ root: fixtures }))
.get('/no_ext')
.expect(shouldNotHaveHeader('Content-Type', t))
.expect(200, err => t.error(err))
.expect(200)
})
t.test('should return Content-Type without charset', function (t) {
t.plan(1)
request(createServer({ root: fixtures }))
await t.test('should return Content-Type without charset', async function (t) {
await request(createServer({ root: fixtures }))
.get('/images/node-js.png')
.expect('Content-Type', 'image/png')
.expect(200, err => t.error(err))
.expect(200)
})
})
})