-
Notifications
You must be signed in to change notification settings - Fork 0
/
string.test.ts
91 lines (83 loc) · 2.11 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
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
import { assertStrictEq, prepareTest } from "../test.mod.ts";
import { extend } from "./extend.ts";
import {
capitalize,
contains,
firstIndex,
firstItem,
insert,
isEmpty,
isString,
lastIndex,
lastItem,
len,
lines,
retain,
splitWhitespace,
toCamelCase,
toKebabCase,
toPascalCase,
toSnakeCase,
toStartCase
} from "./string.ts";
extend({
string: [
capitalize,
contains,
firstIndex,
firstItem,
insert,
isEmpty,
isString,
lastIndex,
lastItem,
len,
lines,
retain,
splitWhitespace,
toCamelCase,
toKebabCase,
toPascalCase,
toSnakeCase,
toStartCase
]
});
async function willExtendStringPrototype() {
const extensions = [
["String.prototype.capitalize", "capitalize"],
["String.prototype.contains", "contains"],
["String.prototype.firstIndex", "firstIndex"],
["String.prototype.firstItem", "firstItem"],
["String.prototype.insert", "insert"],
["String.prototype.isEmpty", "isEmpty"],
["String.prototype.lastIndex", "lastIndex"],
["String.prototype.isEmpty", "isEmpty"],
["String.prototype.lastIndex", "lastIndex"],
["String.prototype.lastItem", "lastItem"],
["String.prototype.len", "len"],
["String.prototype.lines", "lines"],
["String.prototype.retain", "retain"],
["String.prototype.splitWhitespace", "splitWhitespace"],
["String.prototype.toCamelCase", "toCamelCase"],
["String.prototype.toKebabCase", "toKebabCase"],
["String.prototype.toPascalCase", "toPascalCase"],
["String.prototype.toSnakeCase", "toSnakeCase"],
["String.prototype.toStartCase", "toStartCase"]
];
const expectation = extensions.every(([_, methodName]) => {
return methodName in String.prototype;
});
assertStrictEq(expectation, true);
}
async function willExtendStringConstructor() {
const extensions = [["String.isString", "isString"]];
const expectation = extensions.every(([_, methodName]) => {
return methodName in String;
});
assertStrictEq(expectation, true);
}
prepareTest(
[willExtendStringConstructor, willExtendStringPrototype],
"jsmodern",
"string"
);