-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils_test.ts
45 lines (41 loc) · 1.19 KB
/
utils_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
import { stringifyEmbedderPolicy } from "./utils.ts";
import {
assertEquals,
assertThrows,
describe,
EmbedderPolicyValue,
it,
} from "./_dev_deps.ts";
import type { EmbedderPolicy } from "./types.ts";
describe("stringifyEmbedderPolicy", () => {
it("should return string if the input is valid embedder policy", () => {
const table: [EmbedderPolicy, string][] = [
[
{ value: EmbedderPolicyValue.RequireCorp },
EmbedderPolicyValue.RequireCorp,
],
[
{ value: EmbedderPolicyValue.RequireCorp, reportTo: "default" },
`${EmbedderPolicyValue.RequireCorp};report-to=default`,
],
[
{ value: EmbedderPolicyValue.UnsafeNone },
EmbedderPolicyValue.UnsafeNone,
],
];
table.forEach(([embedderPolicy, expected]) => {
assertEquals(
stringifyEmbedderPolicy(embedderPolicy),
expected,
);
});
});
it("should throw error if the iuput is invalid", () => {
const table: EmbedderPolicy[] = [
{ value: EmbedderPolicyValue.Credentialless, reportTo: "?" },
];
table.forEach((embedderPolicy) => {
assertThrows(() => stringifyEmbedderPolicy(embedderPolicy));
});
});
});