forked from CodeGenieApp/serverless-express
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintegration-alb.js
More file actions
37 lines (36 loc) · 1.05 KB
/
integration-alb.js
File metadata and controls
37 lines (36 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const express = require('express')
const serverlessExpress = require('../src/index')
const {
makeEvent,
makeResponse
} = require('../jest-helpers')
describe('alb:express integration tests', () => {
test('response headers are of type string', async () => {
const app = express()
const router = express.Router()
app.use('/', router)
const serverlessExpressInstance = serverlessExpress({ app })
router.get('/foo', (req, res) => {
res.send('123')
})
const event = makeEvent({
eventSourceName: 'AWS_ALB',
path: '/foo',
httpMethod: 'GET',
headers: {}
})
const response = await serverlessExpressInstance(event)
const expectedResponse = makeResponse({
eventSourceName: 'AWS_ALB',
body: '123',
headers: {
'content-length': '3',
'content-type': 'text/html; charset=utf-8',
'x-powered-by': 'Express',
etag: 'W/"3-QL0AFWMIX8NRZTKeof9cXsvbvu8"'
},
multiValueHeaders: undefined
})
expect(response).toMatchObject(expectedResponse)
})
})