forked from claudiajs/claudia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
patch-lambda-function-associations-spec.js
92 lines (88 loc) · 1.9 KB
/
patch-lambda-function-associations-spec.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
const patchLambdaFunctionAssociations = require('../src/tasks/patch-lambda-function-associations');
describe('patchLambdaFunctionAssociations', () => {
'use strict';
it('adds an initial event to an empty array', () => {
expect(patchLambdaFunctionAssociations({
Quantity: 0,
Items: []
}, ['viewer-request'], 'arn:1:2:3')
).toEqual({
Quantity: 1,
Items: [
{
EventType: 'viewer-request',
LambdaFunctionARN: 'arn:1:2:3'
}
]
});
});
it('adds an new event to an existing array', () => {
expect(patchLambdaFunctionAssociations({
Quantity: 1,
Items: [{
EventType: 'viewer-response',
LambdaFunctionARN: 'arn:2:3:4'
}]
}, ['viewer-request'], 'arn:1:2:3')
).toEqual({
Quantity: 2,
Items: [
{
EventType: 'viewer-response',
LambdaFunctionARN: 'arn:2:3:4'
},
{
EventType: 'viewer-request',
LambdaFunctionARN: 'arn:1:2:3'
}
]
});
});
it('replaces an existing event', () => {
expect(patchLambdaFunctionAssociations({
Quantity: 1,
Items: [{
EventType: 'viewer-response',
LambdaFunctionARN: 'arn:2:3:4'
}]
}, ['viewer-response'], 'arn:1:2:3')
).toEqual({
Quantity: 1,
Items: [
{
EventType: 'viewer-response',
LambdaFunctionARN: 'arn:1:2:3'
}
]
});
});
it('works with an array of events', () => {
expect(patchLambdaFunctionAssociations({
Quantity: 1,
Items: [{
EventType: 'viewer-response',
LambdaFunctionARN: 'arn:2:3:4'
}, {
EventType: 'origin-request',
LambdaFunctionARN: 'arn:2:3:4'
}]
}, ['viewer-response', 'origin-response'], 'arn:1:2:3')
).toEqual({
Quantity: 3,
Items: [
{
EventType: 'viewer-response',
LambdaFunctionARN: 'arn:1:2:3'
},
{
EventType: 'origin-request',
LambdaFunctionARN: 'arn:2:3:4'
},
{
EventType: 'origin-response',
LambdaFunctionARN: 'arn:1:2:3'
}
]
});
});
});