-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.ts
115 lines (112 loc) · 5.55 KB
/
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import { assertEqual, test, runTests } from "https://deno.land/x/testing/mod.ts";
import { camelCase } from "mod.ts";
test({name: "camelCase", fn: () => {
assertEqual(camelCase("foo"), "foo");
assertEqual(camelCase("foo-bar"), "fooBar");
assertEqual(camelCase("foo-bar-baz"), "fooBarBaz");
assertEqual(camelCase("foo--bar"), "fooBar");
assertEqual(camelCase("--foo-bar"), "fooBar");
assertEqual(camelCase("--foo--bar"), "fooBar");
assertEqual(camelCase("FOO-BAR"), "fooBar");
assertEqual(camelCase("FOÈ-BAR"), "foèBar");
assertEqual(camelCase("-foo-bar-"), "fooBar");
assertEqual(camelCase("--foo--bar--"), "fooBar");
assertEqual(camelCase("foo.bar"), "fooBar");
assertEqual(camelCase("foo..bar"), "fooBar");
assertEqual(camelCase("..foo..bar.."), "fooBar");
assertEqual(camelCase("foo_bar"), "fooBar");
assertEqual(camelCase("__foo__bar__"), "fooBar");
assertEqual(camelCase("__foo__bar__"), "fooBar");
assertEqual(camelCase("foo bar"), "fooBar");
assertEqual(camelCase(" foo bar "), "fooBar");
assertEqual(camelCase("-"), "-");
assertEqual(camelCase(" - "), "-");
assertEqual(camelCase("fooBar"), "fooBar");
assertEqual(camelCase("fooBar-baz"), "fooBarBaz");
assertEqual(camelCase("foìBar-baz"), "foìBarBaz");
assertEqual(camelCase("fooBarBaz-bazzy"), "fooBarBazBazzy");
assertEqual(camelCase("FBBazzy"), "fbBazzy");
assertEqual(camelCase("F"), "f");
assertEqual(camelCase("FooBar"), "fooBar");
assertEqual(camelCase("Foo"), "foo");
assertEqual(camelCase("FOO"), "foo");
assertEqual(camelCase(["foo", "bar"]), "fooBar");
assertEqual(camelCase(["foo", "-bar"]), "fooBar");
assertEqual(camelCase(["foo", "-bar", "baz"]), "fooBarBaz");
assertEqual(camelCase(["", ""]), "");
assertEqual(camelCase("--"), "");
assertEqual(camelCase(""), "");
assertEqual(camelCase("--__--_--_"), "");
assertEqual(camelCase(["---_", "--", "", "-_- "]), "");
assertEqual(camelCase("foo bar?"), "fooBar?");
assertEqual(camelCase("foo bar!"), "fooBar!");
assertEqual(camelCase("foo bar$"), "fooBar$");
assertEqual(camelCase("foo-bar#"), "fooBar#");
assertEqual(camelCase("XMLHttpRequest"), "xmlHttpRequest");
assertEqual(camelCase("AjaxXMLHttpRequest"), "ajaxXmlHttpRequest");
assertEqual(camelCase("Ajax-XMLHttpRequest"), "ajaxXmlHttpRequest");
assertEqual(camelCase([]), "");
}});
test({name: "camelCase with pascalCase option", fn: () => {
assertEqual(camelCase("foo", { pascalCase: true }), "Foo");
assertEqual(camelCase("foo-bar", { pascalCase: true }), "FooBar");
assertEqual(camelCase("foo-bar-baz", { pascalCase: true }), "FooBarBaz");
assertEqual(camelCase("foo--bar", { pascalCase: true }), "FooBar");
assertEqual(camelCase("--foo-bar", { pascalCase: true }), "FooBar");
assertEqual(camelCase("--foo--bar", { pascalCase: true }), "FooBar");
assertEqual(camelCase("FOO-BAR", { pascalCase: true }), "FooBar");
assertEqual(camelCase("FOÈ-BAR", { pascalCase: true }), "FoèBar");
assertEqual(camelCase("-foo-bar-", { pascalCase: true }), "FooBar");
assertEqual(camelCase("--foo--bar--", { pascalCase: true }), "FooBar");
assertEqual(camelCase("foo.bar", { pascalCase: true }), "FooBar");
assertEqual(camelCase("foo..bar", { pascalCase: true }), "FooBar");
assertEqual(camelCase("..foo..bar..", { pascalCase: true }), "FooBar");
assertEqual(camelCase("foo_bar", { pascalCase: true }), "FooBar");
assertEqual(camelCase("__foo__bar__", { pascalCase: true }), "FooBar");
assertEqual(camelCase("__foo__bar__", { pascalCase: true }), "FooBar");
assertEqual(camelCase("foo bar", { pascalCase: true }), "FooBar");
assertEqual(camelCase(" foo bar ", { pascalCase: true }), "FooBar");
assertEqual(camelCase("-", { pascalCase: true }), "-");
assertEqual(camelCase(" - ", { pascalCase: true }), "-");
assertEqual(camelCase("fooBar", { pascalCase: true }), "FooBar");
assertEqual(camelCase("fooBar-baz", { pascalCase: true }), "FooBarBaz");
assertEqual(camelCase("foìBar-baz", { pascalCase: true }), "FoìBarBaz");
assertEqual(
camelCase("fooBarBaz-bazzy", { pascalCase: true }),
"FooBarBazBazzy"
);
assertEqual(camelCase("FBBazzy", { pascalCase: true }), "FbBazzy");
assertEqual(camelCase("F", { pascalCase: true }), "F");
assertEqual(camelCase("FooBar", { pascalCase: true }), "FooBar");
assertEqual(camelCase("Foo", { pascalCase: true }), "Foo");
assertEqual(camelCase("FOO", { pascalCase: true }), "Foo");
assertEqual(camelCase(["foo", "bar"], { pascalCase: true }), "FooBar");
assertEqual(camelCase(["foo", "-bar"], { pascalCase: true }), "FooBar");
assertEqual(
camelCase(["foo", "-bar", "baz"], { pascalCase: true }),
"FooBarBaz"
);
assertEqual(camelCase(["", ""], { pascalCase: true }), "");
assertEqual(camelCase("--", { pascalCase: true }), "");
assertEqual(camelCase("", { pascalCase: true }), "");
assertEqual(camelCase("--__--_--_", { pascalCase: true }), "");
assertEqual(camelCase(["---_", "--", "", "-_- "], { pascalCase: true }), "");
assertEqual(camelCase("foo bar?", { pascalCase: true }), "FooBar?");
assertEqual(camelCase("foo bar!", { pascalCase: true }), "FooBar!");
assertEqual(camelCase("foo bar$", { pascalCase: true }), "FooBar$");
assertEqual(camelCase("foo-bar#", { pascalCase: true }), "FooBar#");
assertEqual(
camelCase("XMLHttpRequest", { pascalCase: true }),
"XmlHttpRequest"
);
assertEqual(
camelCase("AjaxXMLHttpRequest", { pascalCase: true }),
"AjaxXmlHttpRequest"
);
assertEqual(
camelCase("Ajax-XMLHttpRequest", { pascalCase: true }),
"AjaxXmlHttpRequest"
);
assertEqual(camelCase([], { pascalCase: true }), "");
}});
runTests();