-
-
Notifications
You must be signed in to change notification settings - Fork 450
/
headers.test.ts
45 lines (45 loc) · 1.22 KB
/
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
describe("Headers Tests", () => {
describe("Custom headers defined in next.config.js", () => {
[
{
path: "/ssr-page",
expectedHeaders: { "x-custom-header-ssr-page": "custom" }
},
{
path: "/ssg-page",
expectedHeaders: { "x-custom-header-ssg-page": "custom" }
},
{
path: "/",
expectedHeaders: { "x-custom-header-all": "custom" }
},
{
path: "/not-found",
expectedHeaders: { "x-custom-header-all": "custom" }
},
{
path: "/api/basic-api",
expectedHeaders: { "x-custom-header-api": "custom" }
},
{
path: "/app-store-badge.png",
expectedHeaders: { "x-custom-header-public-file": "custom" }
}
].forEach(({ path, expectedHeaders }) => {
it(`add headers ${JSON.stringify(
expectedHeaders
)} for path ${path}`, () => {
cy.request({
url: path,
failOnStatusCode: false
}).then((response) => {
for (const expectedHeader in expectedHeaders) {
expect(response.headers[expectedHeader]).to.equal(
expectedHeaders[expectedHeader]
);
}
});
});
});
});
});