-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunction.test.js
45 lines (43 loc) · 1.03 KB
/
function.test.js
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
const util = require('./function')
/**
* // unknown
console.log(toPascal('mixed_styleText'))
console.log(toCamelCase('mixed_styleText'))
console.log(toPhp('mixed_styleText'))
console.log(toConstant('mixed_styleText'))
*/
const testArr = [
{
origin: 'it_is_awesome',
camel: 'itIsAwesome',
php: 'it_is_awesome',
constant: 'IT_IS_AWESOME',
pascal: 'ItIsAwesome',
kebab: 'it-is-awesome'
},
{
origin: 'it',
camel: 'it',
php: 'it',
constant: 'IT',
pascal: 'It',
kebab: 'it'
},
{
origin: 'ItIsAwesome',
camel: 'itIsAwesome',
php: 'it_is_awesome',
constant: 'IT_IS_AWESOME',
pascal: 'ItIsAwesome',
kebab: 'it-is-awesome'
}
]
test('Test Transform', () => {
testArr.forEach((item) => {
expect(util.toCamelCase(item.origin)).toBe(item.camel)
expect(util.toConstant(item.origin)).toBe(item.constant)
expect(util.toPascal(item.origin)).toBe(item.pascal)
expect(util.toPhp(item.origin)).toBe(item.php)
expect(util.toKebab(item.origin)).toBe(item.kebab)
})
})