-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils_test.ts
70 lines (60 loc) · 1.56 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { equalsCaseInsensitive, hasToken } from "./utils.ts";
import { type Token } from "./deps.ts";
import { assert, describe, it } from "./_dev_deps.ts";
describe("equalsCaseInsensitive", () => {
it("should return true", () => {
const table: [string, string][] = [
["", ""],
["a", "A"],
["abc", "AbC"],
["あ", "あ"],
];
table.forEach(([left, right]) => {
assert(equalsCaseInsensitive(left, right));
});
});
it("should return false", () => {
const table: [string, string][] = [
["a", "b"],
["ba", "ab"],
["ba", "ab"],
];
table.forEach(([left, right]) => {
assert(!equalsCaseInsensitive(left, right));
});
});
});
describe("hasRangeUnit", () => {
it("should return true", () => {
const table: [string, Token][] = [
["abc", "abc"],
["bytes, test, test2", "bytes"],
["bytes, test, test!", "test"],
[" bytes, test, none ", "none"],
];
table.forEach(([input, token]) => {
assert(hasToken(input, token));
});
});
it("should return false", () => {
const table: [string, Token][] = [
["a", "b"],
["a, b, c", "d"],
["a, b, c", "c,"],
];
table.forEach(([input, token]) => {
assert(!hasToken(input, token));
});
});
it("should return false if the input is invalid syntax", () => {
const table: [string, Token][] = [
["", "a"],
[`"`, "a"],
[`"a"`, "a"],
[`"a", a`, "a"],
];
table.forEach(([input, token]) => {
assert(!hasToken(input, token));
});
});
});