@@ -414,33 +414,6 @@ const handlerWithCustomProps: HandlerFunction<any, RequestContext> = (
414414 res . send ( { status : 'ok' } ) ;
415415} ;
416416
417- const testResponseMethods : HandlerFunction < any , RequestContext > = (
418- req ,
419- res
420- ) => {
421- res . status ( 201 ) ;
422- res . header ( 'X-Custom' , 'value' ) ;
423- res . getHeader ( 'X-Custom' ) ;
424- res . hasHeader ( 'X-Custom' ) ;
425- res . removeHeader ( 'X-Custom' ) ;
426- res . send ( { data : 'raw' } ) ;
427- res . json ( { data : 'json' } ) ;
428- res . html ( '<div>html</div>' ) ;
429- res . redirect ( '/new-location' ) ;
430- res . redirect ( 301 , '/permanent-location' ) ;
431- res . type ( 'json' ) ;
432- res . cookie ( 'session' , 'value' , { httpOnly : true } ) ;
433- res . clearCookie ( 'session' ) ;
434- res . cache ( 3600 ) ;
435- res . cache ( true , true ) ;
436- res . cors ( {
437- origin : '*' ,
438- methods : 'GET, POST' ,
439- headers : 'Content-Type' ,
440- } ) ;
441- res . error ( 400 , 'Bad Request' ) ;
442- } ;
443-
444417const testRequestProperties : HandlerFunction < any , RequestContext > = (
445418 req ,
446419 res
@@ -469,13 +442,50 @@ const testRequestProperties: HandlerFunction<any, RequestContext> = (
469442 req . log . fatal ( 'fatal message' ) ;
470443} ;
471444
445+ const testResponseMethods : HandlerFunction < any , RequestContext > = (
446+ req ,
447+ res
448+ ) => {
449+ res
450+ . status ( 201 )
451+ . header ( 'X-Custom' , 'value' )
452+ . type ( 'json' )
453+ . cors ( {
454+ origin : '*' ,
455+ methods : 'GET, POST' ,
456+ headers : 'Content-Type' ,
457+ } )
458+ . cookie ( 'session' , 'value' , { httpOnly : true } )
459+ . cache ( 3600 )
460+ . etag ( true )
461+ . modified ( new Date ( ) ) ;
462+
463+ expectType < string > ( res . getHeader ( 'X-Custom' ) ) ;
464+ expectType < { [ key : string ] : string } > ( res . getHeaders ( ) ) ;
465+ expectType < boolean > ( res . hasHeader ( 'X-Custom' ) ) ;
466+ res . removeHeader ( 'X-Custom' ) ;
467+
468+ res . send ( { data : 'raw' } ) ;
469+ res . json ( { data : 'json' } ) ;
470+ res . jsonp ( { data : 'jsonp' } ) ;
471+ res . html ( '<div>html</div>' ) ;
472+ res . sendStatus ( 204 ) ;
473+
474+ res . redirect ( '/new-location' ) ;
475+ res . redirect ( 301 , '/permanent-location' ) ;
476+
477+ res . clearCookie ( 'session' ) ;
478+
479+ res . error ( 400 , 'Bad Request' ) ;
480+ res . error ( 'Error message' ) ;
481+ } ;
482+
472483const testErrorHandlingMiddleware : ErrorHandlingMiddleware = async (
473484 error ,
474485 req ,
475486 res ,
476487 next
477488) => {
478- // Test that we can return different types
479489 if ( error . message === 'sync' ) {
480490 return { message : 'handled synchronously' } ;
481491 }
0 commit comments