-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclassify_test.ts
80 lines (79 loc) · 2.06 KB
/
classify_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
import { assertStrictEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
import classify from "./classify.ts";
Deno.test("classify", function () {
assertStrictEquals(
classify("my favorite items"),
"MyFavoriteItems",
"classify normal string",
);
assertStrictEquals(
classify("css-class-name"),
"CssClassName",
"classify dasherized string",
);
assertStrictEquals(
classify("action_name"),
"ActionName",
"classify underscored string",
);
assertStrictEquals(
classify("privateDocs/ownerInvoice"),
"PrivateDocs/OwnerInvoice",
"classify namespaced camelized string",
);
assertStrictEquals(
classify("private_docs/owner_invoice"),
"PrivateDocs/OwnerInvoice",
"classify namespaced underscored string",
);
assertStrictEquals(
classify("private-docs/owner-invoice"),
"PrivateDocs/OwnerInvoice",
"classify namespaced dasherized string",
);
assertStrictEquals(
classify("-view-registry"),
"_ViewRegistry",
"classify prefixed dasherized string",
);
assertStrictEquals(
classify("components/-text-field"),
"Components/_TextField",
"classify namespaced prefixed dasherized string",
);
assertStrictEquals(
classify("_Foo_Bar"),
"_FooBar",
"classify underscore-prefixed underscored string",
);
assertStrictEquals(
classify("_Foo-Bar"),
"_FooBar",
"classify underscore-prefixed dasherized string",
);
assertStrictEquals(
classify("_foo/_bar"),
"_Foo/_Bar",
"classify underscore-prefixed-namespaced underscore-prefixed string",
);
assertStrictEquals(
classify("-foo/_bar"),
"_Foo/_Bar",
"classify dash-prefixed-namespaced underscore-prefixed string",
);
assertStrictEquals(
classify("-foo/-bar"),
"_Foo/_Bar",
"classify dash-prefixed-namespaced dash-prefixed string",
);
assertStrictEquals(
classify("InnerHTML"),
"InnerHTML",
"does nothing with classified string",
);
assertStrictEquals(
classify("_FooBar"),
"_FooBar",
"does nothing with classified prefixed string",
);
});