@@ -144,7 +144,7 @@ describe('composeRouteHandler', () => {
144144
145145 expect ( res . getStatus ( ) ) . toBe ( 200 ) ;
146146 expect ( res . getContentType ( ) ) . toBe ( 'application/json; charset=utf-8' ) ;
147- expect ( res . getBody ( ) ) . toBe ( JSON . stringify ( { ok : true } ) ) ;
147+ expect ( res . getBody ( ) ) . toEqual ( { ok : true } ) ;
148148 expect ( handler ) . toHaveBeenCalledTimes ( 1 ) ;
149149 } ) ;
150150 } ) ;
@@ -354,7 +354,7 @@ describe('composeRouteHandler', () => {
354354 expect ( res . getStatus ( ) ) . toBe ( 200 ) ;
355355 expect ( handler ) . toHaveBeenCalledTimes ( 1 ) ;
356356
357- const responseBody = JSON . parse ( res . getBody ( ) as string ) ;
357+ const responseBody = res . getBody ( ) as any ;
358358 expect ( responseBody . body ) . toEqual ( { test : 'data' , __validated : 'body' } ) ;
359359 expect ( responseBody . params ) . toEqual ( { __validated : 'params' } ) ;
360360 expect ( responseBody . queries ) . toEqual ( { __validated : 'queries' } ) ;
@@ -386,7 +386,7 @@ describe('composeRouteHandler', () => {
386386 expect ( routeOnFail ) . toHaveBeenCalledTimes ( 1 ) ;
387387 expect ( instanceOnFail ) . not . toHaveBeenCalled ( ) ;
388388 expect ( res . getStatus ( ) ) . toBe ( 400 ) ;
389- expect ( JSON . parse ( res . getBody ( ) as string ) . error . message ) . toBe ( 'route handled' ) ;
389+ expect ( ( res . getBody ( ) as any ) . error . message ) . toBe ( 'route handled' ) ;
390390 expect ( handler ) . not . toHaveBeenCalled ( ) ;
391391 } ) ;
392392
@@ -413,7 +413,7 @@ describe('composeRouteHandler', () => {
413413 expect ( routeOnFail ) . toHaveBeenCalledTimes ( 1 ) ;
414414 expect ( instanceOnFail ) . toHaveBeenCalledTimes ( 1 ) ;
415415 expect ( res . getStatus ( ) ) . toBe ( 400 ) ;
416- expect ( JSON . parse ( res . getBody ( ) as string ) . error . message ) . toBe ( 'instance handled' ) ;
416+ expect ( ( res . getBody ( ) as any ) . error . message ) . toBe ( 'instance handled' ) ;
417417 expect ( handler ) . not . toHaveBeenCalled ( ) ;
418418 } ) ;
419419
@@ -534,7 +534,7 @@ describe('composeRouteHandler', () => {
534534 expect ( routeOnFail ) . toHaveBeenCalledTimes ( 1 ) ;
535535 expect ( instanceOnFail ) . not . toHaveBeenCalled ( ) ;
536536 expect ( res . getStatus ( ) ) . toBe ( 400 ) ;
537- expect ( JSON . parse ( res . getBody ( ) as string ) . error . message ) . toBe ( 'route handled response failure' ) ;
537+ expect ( ( res . getBody ( ) as any ) . error . message ) . toBe ( 'route handled response failure' ) ;
538538 } ) ;
539539
540540 test ( 'stops early at instance handler' , async ( ) => {
@@ -560,7 +560,7 @@ describe('composeRouteHandler', () => {
560560 expect ( routeOnFail ) . toHaveBeenCalledTimes ( 1 ) ;
561561 expect ( instanceOnFail ) . toHaveBeenCalledTimes ( 1 ) ;
562562 expect ( res . getStatus ( ) ) . toBe ( 400 ) ;
563- expect ( JSON . parse ( res . getBody ( ) as string ) . error . message ) . toBe ( 'instance handled response failure' ) ;
563+ expect ( ( res . getBody ( ) as any ) . error . message ) . toBe ( 'instance handled response failure' ) ;
564564 } ) ;
565565
566566 test ( 'cascades through all handlers to fallback' , async ( ) => {
@@ -631,7 +631,7 @@ describe('composeRouteHandler', () => {
631631 expect ( errorHook2 ) . toHaveBeenCalledTimes ( 1 ) ;
632632 expect ( errorHook3 ) . not . toHaveBeenCalled ( ) ;
633633 expect ( res . getStatus ( ) ) . toBe ( 400 ) ;
634- expect ( JSON . parse ( res . getBody ( ) as string ) . error . message ) . toBe ( 'handled by hook2' ) ;
634+ expect ( ( res . getBody ( ) as any ) . error . message ) . toBe ( 'handled by hook2' ) ;
635635 } ) ;
636636
637637 test ( 'falls back to 500 when no error hook handles' , async ( ) => {
@@ -674,7 +674,7 @@ describe('composeRouteHandler', () => {
674674 expect ( errorHook2 ) . toHaveBeenCalledTimes ( 1 ) ;
675675 expect ( errorHook3 ) . not . toHaveBeenCalled ( ) ;
676676 expect ( res . getStatus ( ) ) . toBe ( 400 ) ;
677- expect ( JSON . parse ( res . getBody ( ) as string ) . error . message ) . toBe ( 'recovered by hook2' ) ;
677+ expect ( ( res . getBody ( ) as any ) . error . message ) . toBe ( 'recovered by hook2' ) ;
678678 } ) ;
679679 } ) ;
680680} ) ;
0 commit comments