@@ -7,7 +7,7 @@ import { HttpError } from './HttpError';
77const path = '/' ;
88
99test ( 'HttpError with statusText (HTTP/1.1)' , async ( ) => {
10- expect . assertions ( 4 ) ;
10+ expect . assertions ( 6 ) ;
1111
1212 const server = createTestServer ( { silenceErrors : true } ) ;
1313
@@ -24,6 +24,8 @@ test('HttpError with statusText (HTTP/1.1)', async () => {
2424 /* eslint-disable jest/no-conditional-expect */
2525 expect ( name ) . toEqual ( 'HttpError' ) ;
2626 expect ( message ) . toEqual ( 'Not Found' ) ;
27+ expect ( response . status ) . toEqual ( 404 ) ;
28+ expect ( response . statusText ) . toEqual ( 'Not Found' ) ;
2729 expect ( response . headers . get ( 'content-type' ) ) . toEqual ( 'application/json; charset=utf-8' ) ;
2830 expect ( await response . json ( ) ) . toEqual ( {
2931 error : 'Not Found' ,
@@ -54,17 +56,23 @@ test('HttpError without statusText because of HTTP/2', async () => {
5456 ) ;
5557 expect ( e . name ) . toEqual ( 'HttpError' ) ;
5658 expect ( e . message ) . toEqual ( 'Not Found' ) ;
59+ expect ( e . response . status ) . toEqual ( 404 ) ;
60+ expect ( e . response . statusText ) . toEqual ( 'Not Found' ) ;
5761 expect ( await e . response . json ( ) ) . toEqual ( body ) ;
5862
5963 // Without statusText
6064 e = new HttpError ( new Response ( JSON . stringify ( body ) , { status : 404 } ) ) ;
6165 expect ( e . name ) . toEqual ( 'HttpError' ) ;
6266 expect ( e . message ) . toEqual ( '404' ) ;
67+ expect ( e . response . status ) . toEqual ( 404 ) ;
68+ expect ( e . response . statusText ) . toEqual ( '' ) ;
6369 expect ( await e . response . json ( ) ) . toEqual ( body ) ;
6470
6571 // With empty statusText
6672 e = new HttpError ( new Response ( JSON . stringify ( body ) , { status : 404 , statusText : '' } ) ) ;
6773 expect ( e . name ) . toEqual ( 'HttpError' ) ;
6874 expect ( e . message ) . toEqual ( '404' ) ;
75+ expect ( e . response . status ) . toEqual ( 404 ) ;
76+ expect ( e . response . statusText ) . toEqual ( '' ) ;
6977 expect ( await e . response . json ( ) ) . toEqual ( body ) ;
7078} ) ;
0 commit comments