-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
118 lines (102 loc) · 5.36 KB
/
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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/* global describe, it */
var assert = require('assert')
var changeCase = require('./')
describe('change case', function () {
it('should convert to lower case', function () {
assert.equal(changeCase.lower('test'), 'test')
assert.equal(changeCase.lowerCase('TEST'), 'test')
})
it('should convert to upper case', function () {
assert.equal(changeCase.upper('TEST'), 'TEST')
assert.equal(changeCase.upperCase('test'), 'TEST')
})
it('should upper case the first character', function () {
assert.equal(changeCase.ucFirst('TEST'), 'TEST')
assert.equal(changeCase.upperCaseFirst('test'), 'Test')
})
it('should lower case the first character', function () {
assert.equal(changeCase.lcFirst('TEST'), 'tEST')
assert.equal(changeCase.lowerCaseFirst('Test'), 'test')
})
it('should determine whether a string is all upper case or not', function () {
assert.equal(changeCase.isUpper('ALLUPPERCASE'), true)
assert.equal(changeCase.isUpperCase('NotAllUpperCase'), false)
assert.equal(changeCase.isUpperCase('alllowercase'), false)
})
it('should determine whether a string is all upper case or not', function () {
assert.equal(changeCase.isLower('ALLUPPERCASE'), false)
assert.equal(changeCase.isLowerCase('NotAllLowerCase'), false)
assert.equal(changeCase.isLowerCase('alllowercase'), true)
})
it('should convert to title case', function () {
assert.equal(changeCase.title('a test sentence'), 'A Test Sentence')
assert.equal(changeCase.titleCase('i found a bug'), 'I Found A Bug')
assert.equal(changeCase.titleCase("some things'"), 'Some Things')
assert.equal(changeCase.titleCase('"quotes"'), 'Quotes')
assert.equal(changeCase.titleCase('hyphen-ness'), 'Hyphen Ness')
})
it('should convert to sentence case', function () {
assert.equal(changeCase.sentence('a-simple-test'), 'a simple test')
assert.equal(changeCase.sentenceCase('this is a test'), 'this is a test')
assert.equal(changeCase.sentenceCase('this_is_a_test'), 'this is a test')
assert.equal(changeCase.sentenceCase('this-is-a-test'), 'this is a test')
})
it('should convert to camel case', function () {
assert.equal(changeCase.camel('TestString'), 'testString')
assert.equal(changeCase.camelCase('Test String'), 'testString')
assert.equal(changeCase.camelCase('Test_String'), 'testString')
assert.equal(changeCase.camelCase('Test-String'), 'testString')
assert.equal(changeCase.camelCase('Facebook API'), 'facebookApi')
assert.equal(changeCase.camelCase('-webkit-transform'), 'webkitTransform')
assert.equal(changeCase.camelCase('fooBarBaz'), 'fooBarBaz')
assert.equal(changeCase.camelCase('some (things)'), 'someThings')
})
it('should convert to pascal case', function () {
assert.equal(changeCase.pascal('testString'), 'TestString')
assert.equal(changeCase.pascalCase('Test String'), 'TestString')
assert.equal(changeCase.pascalCase('Test_String'), 'TestString')
assert.equal(changeCase.pascalCase('Test-String'), 'TestString')
assert.equal(changeCase.pascalCase('Facebook API'), 'FacebookApi')
assert.equal(changeCase.pascalCase('a-test-again'), 'ATestAgain')
assert.equal(changeCase.pascalCase('a---better__test'), 'ABetterTest')
})
it('should convert to snake case', function () {
assert.equal(changeCase.snake('testString'), 'test_string')
assert.equal(changeCase.snakeCase('Test String'), 'test_string')
assert.equal(changeCase.snakeCase('Test_String'), 'test_string')
assert.equal(changeCase.snakeCase('Test-String'), 'test_string')
assert.equal(changeCase.snakeCase('a---better__test'), 'a_better_test')
})
it('should convert to param case', function () {
assert.equal(changeCase.param('testString'), 'test-string')
assert.equal(changeCase.paramCase('Test String'), 'test-string')
assert.equal(changeCase.paramCase('Test_String'), 'test-string')
assert.equal(changeCase.paramCase('Test-String'), 'test-string')
assert.equal(changeCase.paramCase('a---better__test'), 'a-better-test')
})
it('should convert to constant case', function () {
assert.equal(changeCase.constant('testString'), 'TEST_STRING')
assert.equal(changeCase.constantCase('Test String'), 'TEST_STRING')
assert.equal(changeCase.constantCase('Test_String'), 'TEST_STRING')
assert.equal(changeCase.constantCase('Test-String'), 'TEST_STRING')
assert.equal(changeCase.constantCase('a---better__test'), 'A_BETTER_TEST')
})
it('should convert to dot case', function () {
assert.equal(changeCase.dot('testString'), 'test.string')
assert.equal(changeCase.dotCase('Test String'), 'test.string')
assert.equal(changeCase.dotCase('Test_String'), 'test.string')
assert.equal(changeCase.dotCase('Test-String'), 'test.string')
assert.equal(changeCase.dotCase('a---better__test'), 'a.better.test')
})
it('should convert to path case', function () {
assert.equal(changeCase.path('testString'), 'test/string')
assert.equal(changeCase.pathCase('Test String'), 'test/string')
assert.equal(changeCase.pathCase('Test_String'), 'test/string')
assert.equal(changeCase.pathCase('Test-String'), 'test/string')
assert.equal(changeCase.pathCase('a---better__test'), 'a/better/test')
})
it('should swap the cases', function () {
assert.equal(changeCase.swap('RaNdOMcasE'), 'rAnDomCASe')
assert.equal(changeCase.swapCase('mIX It.Down?'), 'Mix iT.dOWN?')
})
})