File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -406,4 +406,26 @@ describe('HTTP Errors', function () {
406406 assert ( util . isError ( new createError [ '500' ] ( ) ) )
407407 /* eslint-enable node/no-deprecated-api */
408408 } )
409+
410+ it ( 'should interoperate with ES6 classes' , function ( ) {
411+ class MyHttpError extends createError . HttpError {
412+ constructor ( ) {
413+ super ( )
414+ this . name = 'MyHttpError'
415+ this . message = 'ES6 class HTTPError'
416+ this . status = 404
417+ this . myProp = 'test'
418+ }
419+ }
420+
421+ // Testing PR#99: This line should not throw TypeError('cannot construct abstract class')
422+ const err = new MyHttpError ( )
423+ assert . strictEqual ( err . name , 'MyHttpError' )
424+ assert . strictEqual ( err . message , 'ES6 class HTTPError' )
425+ assert . strictEqual ( err . status , 404 )
426+ assert . strictEqual ( err . myProp , 'test' )
427+ /* eslint-disable-next-line node/no-deprecated-api */
428+ assert . strictEqual ( util . isError ( err ) , true )
429+ assert . strictEqual ( createError . isHttpError ( err ) , true )
430+ } )
409431} )
You can’t perform that action at this time.
0 commit comments