-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilter_keys_test.ts
More file actions
31 lines (28 loc) · 984 Bytes
/
filter_keys_test.ts
File metadata and controls
31 lines (28 loc) · 984 Bytes
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
// Copyright 2023-latest the httpland authors. All rights reserved. MIT license.
import { filterHeadersKeys } from "./filter_keys.ts";
import { equalsHeaders } from "./equal.ts";
import { assert, describe, it } from "./_dev_deps.ts";
describe("filterHeadersKeys", () => {
it("should return new headers filtered by predicate", () => {
const table: [Headers, (key: string) => boolean, Headers][] = [
[
new Headers({ "x-test": "test", "date": "xxx" }),
() => true,
new Headers({ "x-test": "test", "date": "xxx" }),
],
[
new Headers({ "x-test": "test", "date": "xxx" }),
() => false,
new Headers(),
],
[
new Headers({ "x-test": "test", "date": "xxx" }),
(key) => key === "date",
new Headers({ date: "xxx" }),
],
];
table.forEach(([headers, predicate, expected]) => {
assert(equalsHeaders(filterHeadersKeys(headers, predicate), expected));
});
});
});