-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod.test.ts
75 lines (73 loc) · 2.78 KB
/
mod.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
import { assertEquals } from "../../test_deps.ts";
import { titleCase } from "./mod.ts";
/**
* Based on https://github.com/gouch/to-title-case/blob/master/test/tests.json.
*/
const TEST_CASES: [string, string][] = [
["", ""],
["2019", "2019"],
["test", "Test"],
["two words", "Two Words"],
["one. two.", "One. Two."],
["a small word starts", "A Small Word Starts"],
["small word ends on", "Small Word Ends On"],
["we keep NASA capitalized", "We Keep NASA Capitalized"],
["pass camelCase through", "Pass camelCase Through"],
["follow step-by-step instructions", "Follow Step-by-Step Instructions"],
["your hair[cut] looks (nice)", "Your Hair[cut] Looks (Nice)"],
["leave Q&A unscathed", "Leave Q&A Unscathed"],
[
"piña colada while you listen to ænima",
"Piña Colada While You Listen to Ænima",
],
["start title – end title", "Start Title – End Title"],
["start title–end title", "Start Title–End Title"],
["start title — end title", "Start Title — End Title"],
["start title—end title", "Start Title—End Title"],
["start title - end title", "Start Title - End Title"],
["don't break", "Don't Break"],
['"double quotes"', '"Double Quotes"'],
['double quotes "inner" word', 'Double Quotes "Inner" Word'],
["fancy double quotes “inner” word", "Fancy Double Quotes “Inner” Word"],
["have you read “The Lottery”?", "Have You Read “The Lottery”?"],
["one: two", "One: Two"],
["one two: three four", "One Two: Three Four"],
['one two: "Three Four"', 'One Two: "Three Four"'],
["email [email protected] address", "Email [email protected] Address"],
[
"you have an https://example.com/ title",
"You Have an https://example.com/ Title",
],
["_underscores around words_", "_Underscores Around Words_"],
["*asterisks around words*", "*Asterisks Around Words*"],
["this vs. that", "This vs. That"],
["this vs that", "This vs That"],
["this v. that", "This v. That"],
["this v that", "This v That"],
[
"Scott Moritz and TheStreet.com’s million iPhone la-la land",
"Scott Moritz and TheStreet.com’s Million iPhone La-La Land",
],
[
"Notes and observations regarding Apple’s announcements from ‘The Beat Goes On’ special event",
"Notes and Observations Regarding Apple’s Announcements From ‘The Beat Goes On’ Special Event",
],
[
"the quick brown fox jumps over the lazy dog",
"The Quick Brown Fox Jumps over the Lazy Dog",
],
["newcastle upon tyne", "Newcastle upon Tyne"],
["newcastle *upon* tyne", "Newcastle *upon* Tyne"],
];
for (const [input, result] of TEST_CASES) {
Deno.test({
name: `case | title_case | ${Deno.inspect(input)} -> ${
Deno.inspect(
result,
)
}`,
fn: () => {
assertEquals(titleCase(input), result);
},
});
}