@@ -19,9 +19,6 @@ describe.each(EACH_MATRIX)('%s:%s: integration tests', (eventSourceName, framewo
19
19
beforeEach ( ( ) => {
20
20
app = express ( )
21
21
router = express . Router ( )
22
- app . set ( 'view engine' , 'ejs' )
23
- app . engine ( '.ejs' , ejs )
24
- app . set ( 'views' , path . join ( jestHelpersPath , 'views' ) )
25
22
app . use ( '/' , router )
26
23
serverlessExpressInstance = serverlessExpress ( { app, log } )
27
24
} )
@@ -37,6 +34,9 @@ describe.each(EACH_MATRIX)('%s:%s: integration tests', (eventSourceName, framewo
37
34
} )
38
35
39
36
test ( 'GET HTML' , async ( ) => {
37
+ app . set ( 'view engine' , 'ejs' )
38
+ app . engine ( '.ejs' , ejs )
39
+ app . set ( 'views' , path . join ( jestHelpersPath , 'views' ) )
40
40
router . get ( '/' , ( req , res ) => {
41
41
const currentInvoke = serverlessExpress . getCurrentInvoke ( )
42
42
const eventPath = currentInvoke . event . path || currentInvoke . event . rawPath || currentInvoke . event . Records [ 0 ] . cf . request . uri
@@ -66,24 +66,42 @@ describe.each(EACH_MATRIX)('%s:%s: integration tests', (eventSourceName, framewo
66
66
} )
67
67
68
68
test ( 'GET JSON' , async ( ) => {
69
- const jsonResponse = { data : { name : 'Brett' } }
69
+ // TODO: Fix lambdaEdge query strings
70
+ const multiValueQueryStringParameters = {
71
+ singleNormal : [ '1' ] ,
72
+ singleSpecial : [ 'hello world!' ] ,
73
+ arr : [ 'a' , 'b' , 'hello world~' ]
74
+ }
75
+ const queryStringParameters = {
76
+ singleNormal : '1' ,
77
+ singleSpecial : 'hello world!' ,
78
+ arr : 'hello world~'
79
+ }
70
80
router . get ( '/users' , ( req , res ) => {
71
- res . set ( 'X-Custom-Header' , 'test' )
72
- res . json ( jsonResponse )
81
+ const { singleNormal, singleSpecial, arr } = req . query
82
+ res . set ( 'X-Custom-Header' , singleNormal )
83
+ res . json ( { singleNormal, singleSpecial, arr } )
73
84
} )
74
85
const event = makeEvent ( {
75
86
eventSourceName,
76
87
path : '/users' ,
77
- httpMethod : 'GET'
88
+ httpMethod : 'GET' ,
89
+ queryStringParameters,
90
+ multiValueQueryStringParameters
78
91
} )
79
92
const response = await serverlessExpressInstance . handler ( event )
80
93
const expectedResponse = makeResponse ( {
81
94
eventSourceName,
82
- body : JSON . stringify ( jsonResponse ) ,
95
+ body : eventSourceName === 'lambdaEdge'
96
+ ? '{}'
97
+ : JSON . stringify ( {
98
+ ...queryStringParameters ,
99
+ arr : multiValueQueryStringParameters . arr
100
+ } ) ,
83
101
multiValueHeaders : {
84
- 'content-length' : [ '25 ' ] ,
85
- etag : [ 'W/"19-dkLV0OMoaMM+tzXUD50EB/AHHoI "' ] ,
86
- 'x-custom-header' : [ 'test ']
102
+ 'content-length' : [ '82 ' ] ,
103
+ etag : eventSourceName === 'lambdaEdge' ? [ 'W/"2-vyGp6PvFo4RvsFtPoIWeCReyIC8"' ] : [ 'W/"52-QR4hWttXm/4xeZPYy7nze/EjYXg "'] ,
104
+ 'x-custom-header' : eventSourceName === 'lambdaEdge' ? [ 'undefined' ] : [ '1 ']
87
105
}
88
106
} )
89
107
expect ( response ) . toEqual ( expectedResponse )
0 commit comments