-
Notifications
You must be signed in to change notification settings - Fork 0
/
stringify_test.ts
50 lines (47 loc) · 1.46 KB
/
stringify_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
// Copyright 2023-latest the httpland authors. All rights reserved. MIT license.
import { stringifyHeaders } from "./stringify.ts";
import { assertEquals, describe, it } from "./_dev_deps.ts";
describe("stringifyHeaders", () => {
it("should return string", () => {
const table: [Headers, string][] = [
[new Headers(), ""],
[new Headers({ "x-test": "test" }), "x-test: test"],
[new Headers({ "X-Test": "test" }), "x-test: test"],
[
new Headers({ "X-Test": "test", origin: "http://example.test" }),
"origin: http://example.test\nx-test: test",
],
[
new Headers({ origin: "http://example.test", "X-Test": "test" }),
"origin: http://example.test\nx-test: test",
],
[
new Headers({
origin: "http://example.test",
"X-Test": "test",
"x-test": "test2",
}),
"origin: http://example.test\nx-test: test, test2",
],
[
new Headers({
origin: "http://example.test",
"X-Test": "test",
"x-test": "test2",
}),
"origin: http://example.test\nx-test: test, test2",
],
[
new Headers({
origin: "http://example.test",
"X-Test": "test",
"x-abc": "abc",
}),
"origin: http://example.test\nx-abc: abc\nx-test: test",
],
];
table.forEach(([headers, expected]) => {
assertEquals(stringifyHeaders(headers), expected);
});
});
});