forked from serverless-nextjs/serverless-next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorigin-with-custom-headers.test.ts
64 lines (55 loc) · 1.46 KB
/
origin-with-custom-headers.test.ts
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
const {
createComponent,
assertHasCacheBehavior,
assertHasOrigin
} = require("../test-utils");
import {
mockCreateDistribution,
mockCreateDistributionPromise
} from "../__mocks__/aws-sdk.mock";
jest.mock("aws-sdk", () => require("../__mocks__/aws-sdk.mock"));
describe("Input origin with custom header", () => {
let component;
beforeEach(async () => {
mockCreateDistributionPromise.mockResolvedValueOnce({
Distribution: {
Id: "xyz"
}
});
component = await createComponent();
});
it("creates distribution with custom url origin", async () => {
await component.default({
origins: [
{
url: "https://exampleorigin.com",
pathPatterns: {
"/some/path": {
minTTL: 10,
defaultTTL: 10,
maxTTL: 10,
allowedHttpMethods: ["GET", "HEAD", "POST"]
}
},
headers: {
"x-api-key": "test"
}
}
]
});
assertHasOrigin(mockCreateDistribution, {
Id: "exampleorigin.com",
DomainName: "exampleorigin.com",
CustomHeaders: {
Quantity: 1,
Items: [{ HeaderName: "x-api-key", HeaderValue: "test" }]
}
});
assertHasCacheBehavior(mockCreateDistribution, {
PathPattern: "/some/path",
MinTTL: 10,
TargetOriginId: "exampleorigin.com"
});
expect(mockCreateDistribution.mock.calls[0][0]).toMatchSnapshot();
});
});