-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathcache-behavior-options.test.js
69 lines (61 loc) · 1.85 KB
/
cache-behavior-options.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
59
60
61
62
63
64
65
66
67
68
69
const { createComponent } = require('../test-utils')
const { mockCreateDistribution, mockCreateDistributionPromise } = require('aws-sdk')
describe('Input origin as a custom url', () => {
let component
beforeEach(async () => {
mockCreateDistributionPromise.mockResolvedValueOnce({
Distribution: {
Id: 'distribution123'
}
})
component = await createComponent()
})
it('creates distribution with custom default behavior options', async () => {
await component.default({
defaults: {
ttl: 0,
forward: {
headers: ['Accept', 'Accept-Language'],
cookies: 'all',
queryString: true,
queryStringCacheKeys: ['query']
},
allowedHttpMethods: ['GET', 'HEAD', 'OPTIONS', 'PUT', 'POST', 'PATCH', 'DELETE'],
viewerProtocolPolicy: 'https-only',
smoothStreaming: true,
compress: true,
fieldLevelEncryptionId: '123'
},
origins: ['https://mycustomorigin.com']
})
expect(mockCreateDistribution.mock.calls[0][0]).toMatchSnapshot()
})
it('creates distribution with custom behavior options', async () => {
await component.default({
defaults: {
ttl: 0
},
origins: [
{
url: 'https://mycustomorigin.com/path',
protocolPolicy: 'http-only',
pathPatterns: {
'/sample/path': {
ttl: 0,
forward: {
headers: 'all',
cookies: ['auth-token'],
queryString: true
},
allowedHttpMethods: ['GET', 'HEAD'],
viewerProtocolPolicy: 'redirect-to-https',
compress: false,
fieldLevelEncryptionId: '321'
}
}
}
]
})
expect(mockCreateDistribution.mock.calls[0][0]).toMatchSnapshot()
})
})