33const Lab = require ( 'lab' )
44const Code = require ( 'code' )
55const Hapi = require ( 'hapi' )
6+ const Boom = require ( 'boom' )
67
78let server
89
9- const { experiment, test , before } = ( exports . lab = Lab . script ( ) )
10+ const { experiment, it , before } = ( exports . lab = Lab . script ( ) )
1011const expect = Code . expect
1112
1213experiment ( '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