-
Notifications
You must be signed in to change notification settings - Fork 0
/
middleware_test.ts
46 lines (41 loc) · 1 KB
/
middleware_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
import { xcto, xctoMiddleware } from "./middleware.ts";
import {
assert,
describe,
Directive,
equalsResponse,
Header,
it,
} from "./_dev_deps.ts";
describe("xcto", () => {
it("should equal", () => {
assert(xcto() === xctoMiddleware);
});
});
describe("xctoMiddleware", () => {
it("should return response what include xcto header", async () => {
const response = await xctoMiddleware(
new Request("test:"),
() => new Response(),
);
assert(
await equalsResponse(
response,
new Response(null, {
headers: { [Header.XContentTypeOptions]: Directive.Nosniff },
}),
true,
),
);
});
it("should return same response if the header include xcto yet", async () => {
const initResponse = new Response(null, {
headers: { [Header.XContentTypeOptions]: "" },
});
const response = await xctoMiddleware(
new Request("test:"),
() => initResponse,
);
assert(response === initResponse);
});
});