Skip to content

Commit 7c8bb1d

Browse files
committed
test: fix GET image test to allow for different last-modified
1 parent 272d810 commit 7c8bb1d

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

__tests__/integration.js

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,39 @@ describe.each(EACH_MATRIX)('%s:%s: integration tests', (eventSourceName, framewo
210210
'accept-ranges': ['bytes'],
211211
'cache-control': ['public, max-age=0'],
212212
'content-length': [15933],
213-
'content-type': ['image/png'],
214-
'etag': ['W/"3e3d-1774e01e5d1"'],
215-
'last-modified': ['Fri, 29 Jan 2021 11:58:03 GMT']
213+
'content-type': ['image/png']
216214
},
217215
isBase64Encoded: true
218216
}, { shouldConvertContentLengthToInt: true })
217+
const etagRegex = /^W\/.*$/
218+
const lastModifiedRegex = /^.* GMT$/
219+
switch (eventSourceName) {
220+
case 'alb':
221+
case 'apiGatewayV1':
222+
expect(response.multiValueHeaders.etag.length).toEqual(1)
223+
expect(response.multiValueHeaders.etag[0]).toMatch(etagRegex)
224+
expect(response.multiValueHeaders['last-modified'].length).toEqual(1)
225+
expect(response.multiValueHeaders['last-modified'][0]).toMatch(lastModifiedRegex)
226+
delete response.multiValueHeaders.etag
227+
delete response.multiValueHeaders['last-modified']
228+
break
229+
case 'apiGatewayV2':
230+
expect(response.headers.etag).toMatch(etagRegex)
231+
expect(response.headers['last-modified']).toMatch(lastModifiedRegex)
232+
delete response.headers.etag
233+
delete response.headers['last-modified']
234+
break
235+
case 'lambdaEdge':
236+
expect(response.headers.etag.length).toEqual(1)
237+
expect(response.headers.etag[0].key).toMatch('etag')
238+
expect(response.headers.etag[0].value).toMatch(etagRegex)
239+
expect(response.headers['last-modified'].length).toEqual(1)
240+
expect(response.headers['last-modified'][0].key).toMatch('last-modified')
241+
expect(response.headers['last-modified'][0].value).toMatch(lastModifiedRegex)
242+
delete response.headers.etag
243+
delete response.headers['last-modified']
244+
break
245+
}
219246
expect(response).toEqual(expectedResponse)
220247
})
221248

0 commit comments

Comments
 (0)