@@ -21,13 +21,9 @@ describe('integration tests', () => {
2121 app = new Application ( ) ;
2222 } ) ;
2323
24- const makeRequestEvent = ( path : string , base ?: RequestEvent , method ?: string ) : RequestEvent => {
25- return _ . extend ( base || apiGatewayRequest ( ) , { path : path , httpMethod : ( method || 'GET' ) } ) ;
26- } ;
27-
2824 const testWithLastResortHandler = ( code : number , desc : string , testHeaders : string [ ] = [ ] , expectedBody = '' ) : void => {
2925 const cb = spy ( ) ,
30- evt = makeRequestEvent ( '/hello/world' , albMultiValHeadersRequest ( ) ) ,
26+ evt = albMultiValHeadersRequest ( '/hello/world' ) ,
3127 headers : StringMap = { } ,
3228 multiValueHeaders : StringArrayOfStringsMap = { } ;
3329
@@ -54,7 +50,7 @@ describe('integration tests', () => {
5450
5551 const testOutcome = ( method : string , path : string , expectedBody : string ) : void => {
5652 const cb = spy ( ) ,
57- evt = makeRequestEvent ( path , apiGatewayRequest ( ) , method ) ;
53+ evt = apiGatewayRequest ( path , method ) ;
5854
5955 app . run ( evt , handlerContext ( ) , cb ) ;
6056
@@ -121,7 +117,7 @@ describe('integration tests', () => {
121117 } ;
122118
123119 it ( 'works - APIGW' , ( ) => {
124- const cb = test ( makeRequestEvent ( '/hello/world' ) ) ;
120+ const cb = test ( apiGatewayRequest ( '/hello/world' ) ) ;
125121
126122 assert . calledWithExactly ( cb , undefined , {
127123 statusCode : 200 ,
@@ -137,7 +133,7 @@ describe('integration tests', () => {
137133 } ) ;
138134
139135 it ( 'works - ALB' , ( ) => {
140- const cb = test ( makeRequestEvent ( '/hello/world' , albRequest ( ) ) ) ;
136+ const cb = test ( albRequest ( '/hello/world' ) ) ;
141137
142138 assert . calledWithExactly ( cb , undefined , {
143139 statusCode : 200 ,
@@ -160,7 +156,7 @@ describe('integration tests', () => {
160156 } ) ;
161157
162158 it ( 'works - ALBMV' , ( ) => {
163- const cb = test ( makeRequestEvent ( '/hello/world' , albMultiValHeadersRequest ( ) ) ) ;
159+ const cb = test ( albMultiValHeadersRequest ( '/hello/world' ) ) ;
164160
165161 assert . calledWithExactly ( cb , undefined , {
166162 statusCode : 200 ,
@@ -209,7 +205,7 @@ describe('integration tests', () => {
209205
210206 // "%EA" is the unicode code point for an "e with circumflex". The client should
211207 // be sending this character using UTF-8 encoding (i.e. %C3%AA)
212- const evt = makeRequestEvent ( '/hello/%EA' , albMultiValHeadersRequest ( ) ) ,
208+ const evt = albMultiValHeadersRequest ( '/hello/%EA' ) ,
213209 cb = spy ( ) ;
214210
215211 app . run ( evt , handlerContext ( ) , cb ) ;
@@ -341,16 +337,16 @@ describe('integration tests', () => {
341337 describe ( 'other HTTP methods' , ( ) => {
342338 // eslint-disable-next-line max-len,max-params
343339 const addTestsForMethod = ( method : string , code : number , desc : string , hdrName : string , hdrVal : string , expectedBody : string , prep : ( ) => void , contentType ?: string ) : void => {
344- const baseEvents = {
345- 'APIGW' : apiGatewayRequest ( ) ,
346- 'ALB' : albRequest ( ) ,
347- 'ALBMV' : albMultiValHeadersRequest ( ) ,
340+ const baseEventGenerators = {
341+ 'APIGW' : apiGatewayRequest ,
342+ 'ALB' : albRequest ,
343+ 'ALBMV' : albMultiValHeadersRequest ,
348344 } ;
349345
350- _ . each ( baseEvents , ( baseEvent , eventTypeName ) => {
346+ _ . each ( baseEventGenerators , ( baseEventGenerator , eventTypeName ) => {
351347 it ( `works with HTTP method ${ method } - ${ eventTypeName } ` , ( ) => {
352348 const cb = spy ( ) ,
353- evt = makeRequestEvent ( '/hello/world' , baseEvent , method ) ;
349+ evt = baseEventGenerator ( '/hello/world' , method ) ;
354350
355351 // this request handler should get run for all methods:
356352 app . all ( '/hello/world' , ( _req : Request , resp : Response , next : NextCallback ) : void => {
@@ -760,7 +756,7 @@ describe('integration tests', () => {
760756 describe ( 'request object' , ( ) => {
761757
762758 it ( 'has an immutable context property' , ( ) => {
763- let evt = makeRequestEvent ( '/test' , apiGatewayRequest ( ) , 'GET' ) ,
759+ let evt = apiGatewayRequest ( '/test' , 'GET' ) ,
764760 ctx = handlerContext ( true ) ,
765761 handler ;
766762
@@ -915,7 +911,7 @@ describe('integration tests', () => {
915911
916912 // "%EA" is the unicode code point for an "e with circumflex". The client should be
917913 // sending this character using UTF-8 encoding (i.e. %C3%AA)
918- const evt = makeRequestEvent ( '/hello/%EA' , albMultiValHeadersRequest ( ) ) ,
914+ const evt = albMultiValHeadersRequest ( '/hello/%EA' ) ,
919915 cb = spy ( ) ;
920916
921917 app . run ( evt , handlerContext ( ) , cb ) ;
0 commit comments