Skip to content

Commit 3047620

Browse files
committed
100% code coverage
1 parent ffcfd66 commit 3047620

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
},
66
"extends": "standard",
77
"parserOptions": {
8-
"ecmaVersion": 8
8+
"ecmaVersion": 2018
99
}
1010
}

test/plugin-skips-non-500-responses.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
const Lab = require('lab')
44
const Code = require('code')
55
const Hapi = require('hapi')
6+
const Boom = require('boom')
67

78
let server
89

9-
const { experiment, test, before } = (exports.lab = Lab.script())
10+
const { experiment, it, before } = (exports.lab = Lab.script())
1011
const expect = Code.expect
1112

1213
experiment('hapi-dev-error works only with 500 errors', () => {
@@ -22,13 +23,11 @@ experiment('hapi-dev-error works only with 500 errors', () => {
2223
})
2324
})
2425

25-
test('test if the plugin skips handling for non-error response', async () => {
26+
it('skips handling for non-error response', async () => {
2627
const routeOptions = {
2728
path: '/ok',
2829
method: 'GET',
29-
handler: () => {
30-
return 'ok'
31-
}
30+
handler: () => 'ok'
3231
}
3332

3433
server.route(routeOptions)
@@ -44,4 +43,22 @@ experiment('hapi-dev-error works only with 500 errors', () => {
4443
expect(response.statusCode).to.equal(200)
4544
expect(payload).to.equal('ok')
4645
})
46+
47+
it('skips handling for 404 errors', async () => {
48+
const routeOptions = {
49+
path: '/404',
50+
method: 'GET',
51+
handler: () => Boom.notFound()
52+
}
53+
54+
server.route(routeOptions)
55+
56+
const request = {
57+
url: routeOptions.path,
58+
method: routeOptions.method
59+
}
60+
61+
const response = await server.inject(request)
62+
expect(response.statusCode).to.equal(404)
63+
})
4764
})

0 commit comments

Comments
 (0)