generated from kawarimidoll/deno-dev-template
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
server_test.ts
52 lines (48 loc) · 1.32 KB
/
server_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
51
52
import { assert, assertEquals } from "./deps.ts";
Deno.env.set("AWS_ACCESS_KEY_ID", "dummy-id");
Deno.env.set("AWS_SECRET_ACCESS_KEY", "dummy-key");
import {
decodeConfig,
encodeConfig,
validateConfig,
validateName,
validateToken,
} from "./server.ts";
Deno.test("encode and decode", () => {
const config = {
description: "<description>",
twitter: "twitter",
list: {
id1: {
icon: "feather/github",
items: [{ icon: "feather/github" }],
},
},
};
const configStr = JSON.stringify(config);
assertEquals(decodeConfig(encodeConfig(configStr)), config);
});
Deno.test("validateConfig", () => {
assert(
validateConfig(
`{"list":{"id1":{"icon":"devicons/github","items":[{"text":"github","link":"https://github.com/"}]}}}`,
),
);
assert(!validateConfig("{}"));
assert(!validateConfig(""));
});
Deno.test("validateName", () => {
assert(validateName("this-is-valid_123"));
assert(!validateName("invalid name"));
assert(!validateName(""));
assert(!validateName("o"));
assert(!validateName("_no"));
assert(!validateName("名前"));
});
Deno.test("validateToken", () => {
assert(validateToken("this-is-valid_123"));
assert(!validateToken("invalid token"));
assert(!validateToken(""));
assert(!validateToken("short"));
assert(!validateToken("秘密"));
});