@@ -21,13 +21,9 @@ describe('integration tests', () => {
21
21
app = new Application ( ) ;
22
22
} ) ;
23
23
24
- const makeRequestEvent = ( path : string , base ?: RequestEvent , method ?: string ) : RequestEvent => {
25
- return _ . extend ( base || apiGatewayRequest ( ) , { path : path , httpMethod : ( method || 'GET' ) } ) ;
26
- } ;
27
-
28
24
const testWithLastResortHandler = ( code : number , desc : string , testHeaders : string [ ] = [ ] , expectedBody = '' ) : void => {
29
25
const cb = spy ( ) ,
30
- evt = makeRequestEvent ( '/hello/world' , albMultiValHeadersRequest ( ) ) ,
26
+ evt = albMultiValHeadersRequest ( '/hello/world' ) ,
31
27
headers : StringMap = { } ,
32
28
multiValueHeaders : StringArrayOfStringsMap = { } ;
33
29
@@ -54,7 +50,7 @@ describe('integration tests', () => {
54
50
55
51
const testOutcome = ( method : string , path : string , expectedBody : string ) : void => {
56
52
const cb = spy ( ) ,
57
- evt = makeRequestEvent ( path , apiGatewayRequest ( ) , method ) ;
53
+ evt = apiGatewayRequest ( path , method ) ;
58
54
59
55
app . run ( evt , handlerContext ( ) , cb ) ;
60
56
@@ -121,7 +117,7 @@ describe('integration tests', () => {
121
117
} ;
122
118
123
119
it ( 'works - APIGW' , ( ) => {
124
- const cb = test ( makeRequestEvent ( '/hello/world' ) ) ;
120
+ const cb = test ( apiGatewayRequest ( '/hello/world' ) ) ;
125
121
126
122
assert . calledWithExactly ( cb , undefined , {
127
123
statusCode : 200 ,
@@ -137,7 +133,7 @@ describe('integration tests', () => {
137
133
} ) ;
138
134
139
135
it ( 'works - ALB' , ( ) => {
140
- const cb = test ( makeRequestEvent ( '/hello/world' , albRequest ( ) ) ) ;
136
+ const cb = test ( albRequest ( '/hello/world' ) ) ;
141
137
142
138
assert . calledWithExactly ( cb , undefined , {
143
139
statusCode : 200 ,
@@ -160,7 +156,7 @@ describe('integration tests', () => {
160
156
} ) ;
161
157
162
158
it ( 'works - ALBMV' , ( ) => {
163
- const cb = test ( makeRequestEvent ( '/hello/world' , albMultiValHeadersRequest ( ) ) ) ;
159
+ const cb = test ( albMultiValHeadersRequest ( '/hello/world' ) ) ;
164
160
165
161
assert . calledWithExactly ( cb , undefined , {
166
162
statusCode : 200 ,
@@ -209,7 +205,7 @@ describe('integration tests', () => {
209
205
210
206
// "%EA" is the unicode code point for an "e with circumflex". The client should
211
207
// 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' ) ,
213
209
cb = spy ( ) ;
214
210
215
211
app . run ( evt , handlerContext ( ) , cb ) ;
@@ -341,16 +337,16 @@ describe('integration tests', () => {
341
337
describe ( 'other HTTP methods' , ( ) => {
342
338
// eslint-disable-next-line max-len,max-params
343
339
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 ,
348
344
} ;
349
345
350
- _ . each ( baseEvents , ( baseEvent , eventTypeName ) => {
346
+ _ . each ( baseEventGenerators , ( baseEventGenerator , eventTypeName ) => {
351
347
it ( `works with HTTP method ${ method } - ${ eventTypeName } ` , ( ) => {
352
348
const cb = spy ( ) ,
353
- evt = makeRequestEvent ( '/hello/world' , baseEvent , method ) ;
349
+ evt = baseEventGenerator ( '/hello/world' , method ) ;
354
350
355
351
// this request handler should get run for all methods:
356
352
app . all ( '/hello/world' , ( _req : Request , resp : Response , next : NextCallback ) : void => {
@@ -760,7 +756,7 @@ describe('integration tests', () => {
760
756
describe ( 'request object' , ( ) => {
761
757
762
758
it ( 'has an immutable context property' , ( ) => {
763
- let evt = makeRequestEvent ( '/test' , apiGatewayRequest ( ) , 'GET' ) ,
759
+ let evt = apiGatewayRequest ( '/test' , 'GET' ) ,
764
760
ctx = handlerContext ( true ) ,
765
761
handler ;
766
762
@@ -915,7 +911,7 @@ describe('integration tests', () => {
915
911
916
912
// "%EA" is the unicode code point for an "e with circumflex". The client should be
917
913
// sending this character using UTF-8 encoding (i.e. %C3%AA)
918
- const evt = makeRequestEvent ( '/hello/%EA' , albMultiValHeadersRequest ( ) ) ,
914
+ const evt = albMultiValHeadersRequest ( '/hello/%EA' ) ,
919
915
cb = spy ( ) ;
920
916
921
917
app . run ( evt , handlerContext ( ) , cb ) ;
0 commit comments