@@ -144,16 +144,22 @@ api9.use(middleware3);
144
144
/*** DEFINE TEST ROUTES ***/
145
145
/******************************************************************************/
146
146
147
- api . get ( '/' , function ( req , res ) {
147
+ api . get ( "/" , function ( req , res ) {
148
148
res . status ( 200 ) . json ( {
149
149
testMiddleware : req . testMiddleware ,
150
150
} )
151
151
} ) ;
152
- api . post ( '/' , function ( req , res ) {
152
+ api . post ( "/" , function ( req , res ) {
153
153
res . status ( 200 ) . json ( {
154
154
testMiddleware2 : req . testMiddleware2 ,
155
155
} )
156
156
} ) ;
157
+ api . any ( "/" , function ( req , res ) {
158
+ res . status ( 200 ) . json ( {
159
+ testMiddleware : req . testMiddleware ,
160
+ testMiddleware2 : req . testMiddleware2 ,
161
+ } )
162
+ } ) ;
157
163
158
164
api . get ( "/test" , function ( req , res ) {
159
165
res . status ( 200 ) . json ( {
@@ -368,6 +374,21 @@ describe("Middleware Tests:", function () {
368
374
} ) ;
369
375
} )
370
376
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
+
371
392
it ( "Set Values in res object" , async function ( ) {
372
393
let _event = Object . assign ( { } , event , { } ) ;
373
394
let result = await new Promise ( ( r ) =>
0 commit comments