@@ -144,16 +144,22 @@ api9.use(middleware3);
144144/*** DEFINE TEST ROUTES ***/
145145/******************************************************************************/
146146
147- api . get ( '/' , function ( req , res ) {
147+ api . get ( "/" , function ( req , res ) {
148148 res . status ( 200 ) . json ( {
149149 testMiddleware : req . testMiddleware ,
150150 } )
151151} ) ;
152- api . post ( '/' , function ( req , res ) {
152+ api . post ( "/" , function ( req , res ) {
153153 res . status ( 200 ) . json ( {
154154 testMiddleware2 : req . testMiddleware2 ,
155155 } )
156156} ) ;
157+ api . any ( "/" , function ( req , res ) {
158+ res . status ( 200 ) . json ( {
159+ testMiddleware : req . testMiddleware ,
160+ testMiddleware2 : req . testMiddleware2 ,
161+ } )
162+ } ) ;
157163
158164api . get ( "/test" , function ( req , res ) {
159165 res . status ( 200 ) . json ( {
@@ -368,6 +374,21 @@ describe("Middleware Tests:", function () {
368374 } ) ;
369375 } )
370376
377+ it ( 'should return testMiddleware: 123 when calling the root route with PATCH' , async function ( ) {
378+ let _event = Object . assign ( { } , event , { path : "/" , httpMethod : "PATCH" } ) ;
379+ let result = await new Promise ( ( r ) =>
380+ api . run ( _event , { } , ( e , res ) => {
381+ r ( res ) ;
382+ } )
383+ ) ;
384+ expect ( result ) . toEqual ( {
385+ multiValueHeaders : { "content-type" : [ "application/json" ] } ,
386+ statusCode : 200 ,
387+ body : '{"testMiddleware":"123","testMiddleware2":"456"}' ,
388+ isBase64Encoded : false ,
389+ } ) ;
390+ } )
391+
371392 it ( "Set Values in res object" , async function ( ) {
372393 let _event = Object . assign ( { } , event , { } ) ;
373394 let result = await new Promise ( ( r ) =>
0 commit comments