Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace mocha with tap #10

Merged
merged 3 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .taprc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
files:
- test/**/*.test.js

branches: 96
11 changes: 4 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
"file",
"server"
],
"standard": {
"env": [ "mocha" ]
},
"dependencies": {
"debug": "^4.3.4",
"depd": "2.0.0",
Expand All @@ -35,11 +32,10 @@
},
"devDependencies": {
"after": "0.8.2",
"mocha": "10.2.0",
"nyc": "15.1.0",
"snazzy": "^9.0.0",
"standard": "^17.0.0",
"supertest": "6.3.3"
"supertest": "6.3.3",
"tap": "^16.3.3"
},
"files": [
"HISTORY.md",
Expand All @@ -51,6 +47,7 @@
"scripts": {
"lint": "standard | snazzy",
"lint:fix": "standard --fix | snazzy",
"test": "mocha --check-leaks --reporter spec --bail"
"test": "npm run test:unit",
"test:unit": "tap"
}
}
52 changes: 52 additions & 0 deletions test/mime.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
'use strict'

process.env.NO_DEPRECATION = 'send'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was there before. It is part of depd

https://github.com/dougwilson/nodejs-depd#processenvno_deprecation

We could replace it with processwarning or just rip out the deprecated code out of our fork in a follow up PR


const { test } = require('tap')
const path = require('path')
const request = require('supertest')
const send = require('..')
const { shouldNotHaveHeader, createServer } = require('./utils')

const fixtures = path.join(__dirname, 'fixtures')

test('send.mime', function (t) {
t.plan(2)

t.test('should be exposed', function (t) {
t.plan(1)
t.ok(send.mime)
})

t.test('.default_type', function (t) {
t.plan(2)

t.before(function () {
this.default_type = send.mime.default_type
})

t.afterEach(function () {
send.mime.default_type = this.default_type
})

t.test('should change the default type', function (t) {
t.plan(1)
send.mime.default_type = 'text/plain'

request(createServer({ root: fixtures }))
.get('/no_ext')
.expect('Content-Type', 'text/plain; charset=UTF-8')
.expect(200, () => t.pass())
})

t.test('should not add Content-Type for undefined default', function (t) {
t.plan(2)
send.mime.default_type = undefined

request(createServer({ root: fixtures }))
.get('/no_ext')
.expect(shouldNotHaveHeader('Content-Type', t))
.expect(200, () => t.pass())
})
})
})
Loading