-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
103 lines (100 loc) · 1.96 KB
/
test.js
File metadata and controls
103 lines (100 loc) · 1.96 KB
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
const assert = require('assert');
const casecraft = require('./casecraft');
// Test cases
const tests = [
{
method: 'toSnakeCase',
input: 'HelloWorld',
expected: 'hello_world',
},
{
method: 'toScreamingSnakeCase',
input: 'HelloWorld',
expected: 'HELLO_WORLD',
},
{
method: 'toLowerCase',
input: 'HelloWorld',
expected: 'helloworld',
},
{
method: 'toUpperCase',
input: 'HelloWorld',
expected: 'HELLOWORLD',
},
{
method: 'toCamelCase',
input: 'hello_world',
expected: 'helloWorld',
},
{
method: 'toCamelSnakeCase',
input: 'helloWorld',
expected: 'hello_world',
},
{
method: 'toKebabCase',
input: 'HelloWorld',
expected: 'hello-world',
},
{
method: 'toScreamingKebabCase',
input: 'HelloWorld',
expected: 'HELLO-WORLD',
},
{
method: 'toPascalCase',
input: 'hello_world',
expected: 'HelloWorld',
},
{
method: 'toTrainCase',
input: 'hello_world',
expected: 'Hello-World',
},
{
method: 'toTitleCase',
input: 'hello_world',
expected: 'Hello World',
},
{
method: 'toDotNotation',
input: 'hello_world',
expected: 'hello.world',
},
{
method: 'toPathCase',
input: 'hello_world',
expected: 'hello/world',
},
{
method: 'toSlugCase',
input: 'hello_world',
expected: 'hello-world',
},
{
method: 'toNoSpaces',
input: 'hello world',
expected: 'helloworld',
},
{
method: 'toHumanReadable',
input: 'hello_world',
expected: 'Hello World',
},
{
method: 'toReverseCase',
input: 'HelloWorld',
expected: 'hELLOwORLD',
},
];
// Run tests
tests.forEach(test => {
try {
const result = casecraft[test.method](test.input);
assert.strictEqual(result, test.expected);
console.log(`${test.method} passed!`);
} catch (error) {
console.error(`${test.method} failed: Expected "${test.expected}", got "${casecraft[test.method](test.input)}"`);
}
});