-
-
Notifications
You must be signed in to change notification settings - Fork 793
/
lambdaIntegration.test.js
58 lines (50 loc) · 1.27 KB
/
lambdaIntegration.test.js
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { resolve } from 'path'
import fetch from 'node-fetch'
import { joinUrl, setup, teardown } from '../_testHelpers/index.js'
const { stringify } = JSON
jest.setTimeout(30000)
describe('lambda integration tests', () => {
// init
beforeAll(() =>
setup({
servicePath: resolve(__dirname),
}),
)
// cleanup
afterAll(() => teardown())
//
;[
{
description: 'should return JSON',
expected: {
foo: 'bar',
},
path: '/dev/lambda-integration-json',
status: 200,
},
{
description: 'should return stringified JSON',
expected: stringify({
foo: 'bar',
}),
path: '/dev/lambda-integration-stringified',
status: 200,
},
{
description: 'should return operation name from request context',
expected: {
operationName: 'getIntegrationWithOperationName',
},
path: '/dev/lambda-integration-with-operation-name',
status: 200,
},
].forEach(({ description, expected, path, status }) => {
test(description, async () => {
const url = joinUrl(TEST_BASE_URL, path)
const response = await fetch(url)
expect(response.status).toEqual(status)
const json = await response.json()
expect(json).toEqual(expected)
})
})
})