Skip to content

Commit

Permalink
Update README, package.json, test for release, dropped coveralls
Browse files Browse the repository at this point in the history
Now it requires 100% code coverage
  • Loading branch information
mcollina committed May 1, 2020
1 parent fbd1dce commit 00ca0fe
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .taprc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
esm: false
ts: false
jsx: false
flow: false
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

![CI workflow](https://github.com/fastify/fastify-accepts/workflows/CI%20workflow/badge.svg)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![Coverage Status](https://coveralls.io/repos/github/fastify/fastify-accepts/badge.svg?branch=feature%2Fshortcuts)](https://coveralls.io/github/fastify/fastify-accepts?branch=feature%2Fshortcuts)
[![Known Vulnerabilities](https://snyk.io/test/github/fastify/fastify-accepts/badge.svg)](https://snyk.io/test/github/fastify/fastify-accepts)

Add accepts parser to fastify
Expand Down
3 changes: 1 addition & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ function replyAcceptMethod () {
}

function fastifyAcceptHeader (fastify, options, done) {
options = options || {}
const decorateReplyToo = options.decorateReply

fastify.decorateRequest('accepts', acceptsMethod)
Expand Down Expand Up @@ -58,6 +57,6 @@ function fastifyAcceptHeader (fastify, options, done) {
}

module.exports = fp(fastifyAcceptHeader, {
fastify: '>=3',
fastify: '3.x',
name: 'fastify-accepts'
})
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"devDependencies": {
"@types/accepts": "^1.3.5",
"@types/node": "^13.1.8",
"coveralls": "^3.0.0",
"fastify": "^3.0.0-rc.1",
"pre-commit": "^1.2.2",
"request": "^2.88.0",
Expand All @@ -25,10 +24,8 @@
},
"scripts": {
"lint": "standard | snazzy",
"unit": "tap test.js",
"unit": "tap --100 test.js",
"test": "npm run lint && npm run unit && npm run typescript",
"coverage": "tap test.js --cov --coverage-report=text-lcov --coverage-report=html",
"coveralls": "tap test.js --cov --coverage-report=text-lcov | coveralls",
"typescript": "tsd"
},
"repository": {
Expand Down
19 changes: 18 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ test('accept header', t => {
const fastify = Fastify()
fastify.register(plugin, { decorateReply: true })

t.tearDown(fastify.close.bind(fastify))

fastify.get('/request', function (req, reply) {
reply.send({
types: req.types(),
Expand Down Expand Up @@ -133,6 +135,21 @@ test('accept header', t => {
})
})
})
})

test('no reply decorator', async function (t) {
const fastify = Fastify()
fastify.register(plugin, { decorateReply: false })
await fastify.ready()

const methodNames = [
'Charset', 'Charsets',
'Encoding', 'Encodings',
'Language', 'Languages',
'Type', 'Types'
]

fastify.server.unref()
for (const method of methodNames) {
t.is(fastify.hasReplyDecorator('request' + method, false), false)
}
})

0 comments on commit 00ca0fe

Please sign in to comment.