-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstring.test.ts
48 lines (42 loc) · 1.26 KB
/
string.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
import { camelize, toSlug } from "./string.ts";
import { assertEquals } from "./test_deps.ts";
Deno.test("camelise", async (t) => {
await t.step("kebab-case", () => {
assertEquals(camelize("kebab-cased-string"), "kebabCasedString");
assertEquals(
camelize("screaming-kebab-cased-string"),
"screamingKebabCasedString",
);
});
await t.step("snake_case", () => {
assertEquals(camelize("snake_cased_string"), "snakeCasedString");
assertEquals(
camelize("SCREAMING_SNAKE_CASED_STRING"),
"screamingSnakeCasedString",
);
});
await t.step("string with spaces", () => {
assertEquals(camelize("string with Spaces"), "stringWithSpaces");
assertEquals(camelize("CAPS LOCK STRING"), "capsLockString");
});
await t.step("mixed case", () => {
assertEquals(
camelize("string WITH spaces_and_snakes-with-kebabs"),
"stringWithSpacesAndSnakesWithKebabs",
);
});
await t.step("acronyms", () => {
assertEquals(
camelize("initialize_SDK_with_options"),
"initializeSdkWithOptions",
);
});
});
Deno.test("toSlug", async (t) => {
await t.step("string with spaces", () => {
assertEquals(
toSlug("Chapter 1: Hello World (again)"),
"chapter-1-hello-world-again",
);
});
});