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

feat: move to tap15 #55

Merged
merged 2 commits into from
Apr 6, 2021
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
1 change: 1 addition & 0 deletions .taprc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
check-coverage: false
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@types/node": "^14.0.1",
"fastify": "^3.0.0",
"standard": "^16.0.1",
"tap": "^14.10.7",
"tap": "^15.0.2",
"tsd": "^0.14.0"
},
"dependencies": {
Expand Down
8 changes: 4 additions & 4 deletions test/assert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ test('Should support strict equal assert (throw)', t => {
fastify.ready(err => {
t.error(err)
try {
fastify.assert.strictEqual(1, 2)
fastify.assert.equal(1, 2)
t.fail('Should throw')
} catch (err) {
t.ok(err)
Expand Down Expand Up @@ -255,9 +255,9 @@ test('Should generate the correct http error', t => {
fastify.assert(false, 400, 'Wrong!')
t.fail('Should throw')
} catch (err) {
t.is(err.message, 'Wrong!')
t.is(err.name, 'BadRequestError')
t.is(err.statusCode, 400)
t.equal(err.message, 'Wrong!')
t.equal(err.name, 'BadRequestError')
t.equal(err.statusCode, 400)
}
})
})
24 changes: 12 additions & 12 deletions test/errorHandler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ test('The custom error handler should hide the error message for 500s', t => {
url: '/'
}, (err, res) => {
t.error(err)
t.strictEqual(res.statusCode, 500)
t.deepEqual(JSON.parse(res.payload), {
t.equal(res.statusCode, 500)
t.same(JSON.parse(res.payload), {
error: 'Internal Server Error',
message: 'Something went wrong',
statusCode: 500
Expand All @@ -43,8 +43,8 @@ test('The custom error handler can be disabled', t => {
url: '/'
}, (err, res) => {
t.error(err)
t.strictEqual(res.statusCode, 500)
t.deepEqual(JSON.parse(res.payload), {
t.equal(res.statusCode, 500)
t.same(JSON.parse(res.payload), {
error: 'Internal Server Error',
message: 'kaboom',
statusCode: 500
Expand All @@ -69,8 +69,8 @@ test('The custom error handler should hide the error message for 500s (promise)'
url: '/'
}, (err, res) => {
t.error(err)
t.strictEqual(res.statusCode, 500)
t.deepEqual(JSON.parse(res.payload), {
t.equal(res.statusCode, 500)
t.same(JSON.parse(res.payload), {
error: 'Internal Server Error',
message: 'Something went wrong',
statusCode: 500
Expand All @@ -93,8 +93,8 @@ test('Should hide only 500s', t => {
url: '/'
}, (err, res) => {
t.error(err)
t.strictEqual(res.statusCode, 502)
t.deepEqual(JSON.parse(res.payload), {
t.equal(res.statusCode, 502)
t.same(JSON.parse(res.payload), {
error: 'Bad Gateway',
message: 'kaboom',
statusCode: 502
Expand All @@ -120,8 +120,8 @@ test('Should hide only 500s (promise)', t => {
url: '/'
}, (err, res) => {
t.error(err)
t.strictEqual(res.statusCode, 502)
t.deepEqual(JSON.parse(res.payload), {
t.equal(res.statusCode, 502)
t.same(JSON.parse(res.payload), {
error: 'Bad Gateway',
message: 'kaboom',
statusCode: 502
Expand Down Expand Up @@ -150,8 +150,8 @@ test('Override error handler', t => {
url: '/'
}, (err, res) => {
t.error(err)
t.strictEqual(res.statusCode, 500)
t.deepEqual(JSON.parse(res.payload), {
t.equal(res.statusCode, 500)
t.same(JSON.parse(res.payload), {
error: 'Internal Server Error',
message: 'kaboom',
statusCode: 500
Expand Down
8 changes: 4 additions & 4 deletions test/forwarded.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ test('request.forwarded API', t => {
}
}, (err, res) => {
t.error(err)
t.strictEqual(res.statusCode, 200)
t.deepEqual(
t.equal(res.statusCode, 200)
t.same(
JSON.parse(res.payload),
['127.0.0.1', '10.0.0.1', '10.0.0.2']
)
Expand All @@ -45,8 +45,8 @@ test('request.forwarded API (without header)', t => {
url: '/'
}, (err, res) => {
t.error(err)
t.strictEqual(res.statusCode, 200)
t.deepEqual(
t.equal(res.statusCode, 200)
t.same(
JSON.parse(res.payload),
['127.0.0.1']
)
Expand Down
22 changes: 11 additions & 11 deletions test/httpErrors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ test('Should generate the correct http error', t => {
t.ok(err instanceof HttpError)
// `statusCodes` uses the capital T
if (err.message === 'I\'m a teapot') {
t.is(err.statusCode, 418)
t.equal(err.statusCode, 418)
} else {
t.is(err.message, statusCodes[code])
t.equal(err.message, statusCodes[code])
}
t.is(typeof err.name, 'string')
t.is(err.statusCode, Number(code))
t.equal(typeof err.name, 'string')
t.equal(err.statusCode, Number(code))
})

t.end()
Expand All @@ -48,7 +48,7 @@ test('Should expose the createError method from http-errors', t => {
fastify.ready(err => {
t.error(err)

t.is(fastify.httpErrors.createError, createError)
t.equal(fastify.httpErrors.createError, createError)
t.end()
})
})
Expand All @@ -61,9 +61,9 @@ test('Should generate the correct error using the properties given', t => {
t.error(err)
const customError = fastify.httpErrors.createError(404, 'This video does not exist!')
t.ok(customError instanceof HttpError)
t.is(customError.message, 'This video does not exist!')
t.is(typeof customError.name, 'string')
t.is(customError.statusCode, 404)
t.equal(customError.message, 'This video does not exist!')
t.equal(typeof customError.name, 'string')
t.equal(customError.statusCode, 404)
t.end()
})
})
Expand All @@ -80,9 +80,9 @@ test('Should generate the correct http error (with custom message)', t => {
const name = normalize(code, statusCodes[code])
const err = fastify.httpErrors[name]('custom')
t.ok(err instanceof HttpError)
t.is(err.message, 'custom')
t.is(typeof err.name, 'string')
t.is(err.statusCode, Number(code))
t.equal(err.message, 'custom')
t.equal(typeof err.name, 'string')
t.equal(err.statusCode, Number(code))
})

t.end()
Expand Down
10 changes: 5 additions & 5 deletions test/httpErrorsReply.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ test('Should generate the correct http error', t => {
url: '/'
}, (err, res) => {
t.error(err)
t.strictEqual(res.statusCode, Number(code))
t.equal(res.statusCode, Number(code))
if (code === '418') {
// https://github.com/fastify/fastify/blob/b96934d46091bb1c93f55b07149520bb9e5c0729/lib/reply.js#L350-L355
t.deepEqual(JSON.parse(res.payload), {
t.same(JSON.parse(res.payload), {
error: node10 ? 'I\'m a Teapot' : 'I\'m a teapot',
message: 'I\'m a teapot',
statusCode: 418
})
} else {
t.deepEqual(JSON.parse(res.payload), {
t.same(JSON.parse(res.payload), {
error: statusCodes[code],
message: statusCodes[code],
statusCode: Number(code)
Expand Down Expand Up @@ -73,8 +73,8 @@ test('Should generate the correct http error (with custom message)', t => {
url: '/'
}, (err, res) => {
t.error(err)
t.strictEqual(res.statusCode, Number(code))
t.deepEqual(JSON.parse(res.payload), {
t.equal(res.statusCode, Number(code))
t.same(JSON.parse(res.payload), {
error: statusCodes[code],
message: 'custom',
statusCode: Number(code)
Expand Down
8 changes: 4 additions & 4 deletions test/is.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ test('request.is API', t => {
payload: { foo: 'bar' }
}, (err, res) => {
t.error(err)
t.strictEqual(res.statusCode, 200)
t.deepEqual(
t.equal(res.statusCode, 200)
t.same(
res.payload,
'json'
)
Expand All @@ -44,8 +44,8 @@ test('request.is API (with array)', t => {
payload: { foo: 'bar' }
}, (err, res) => {
t.error(err)
t.strictEqual(res.statusCode, 200)
t.deepEqual(
t.equal(res.statusCode, 200)
t.same(
res.payload,
'json'
)
Expand Down
12 changes: 6 additions & 6 deletions test/vary.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ test('reply.vary API', t => {
url: '/'
}, (err, res) => {
t.error(err)
t.strictEqual(res.statusCode, 200)
t.strictEqual(res.headers.vary, 'Accept, Origin, User-Agent')
t.strictEqual(res.payload, 'ok')
t.equal(res.statusCode, 200)
t.equal(res.headers.vary, 'Accept, Origin, User-Agent')
t.equal(res.payload, 'ok')
})
})

Expand All @@ -35,7 +35,7 @@ test('reply.vary.append API', t => {
fastify.register(Sensible)

fastify.get('/', (req, reply) => {
t.strictEqual(
t.equal(
reply.vary.append('', ['Accept', 'Accept-Language']), 'Accept, Accept-Language'
)
reply.send('ok')
Expand All @@ -46,7 +46,7 @@ test('reply.vary.append API', t => {
url: '/'
}, (err, res) => {
t.error(err)
t.strictEqual(res.statusCode, 200)
t.strictEqual(res.payload, 'ok')
t.equal(res.statusCode, 200)
t.equal(res.payload, 'ok')
})
})