Skip to content

Commit af82cdb

Browse files
committed
added tests
1 parent 0117ca8 commit af82cdb

File tree

5 files changed

+80
-16
lines changed

5 files changed

+80
-16
lines changed

.jshintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.jshintrc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"node": true,
3+
4+
"curly": true,
5+
"latedef": true,
6+
"quotmark": true,
7+
"undef": true,
8+
"unused": true,
9+
"trailing": true,
10+
"globals": {
11+
"describe": false,
12+
"xdescribe": false,
13+
"ddescribe": false,
14+
"it": false,
15+
"xit": false,
16+
"iit": false,
17+
"beforeEach": false,
18+
"afterEach": false,
19+
"pending": false,
20+
"spyOn": false
21+
}
22+
}

index.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var mapObj = require('map-obj');
24
var camelCase = require('camelcase');
35
var _ = require('lodash');
@@ -30,16 +32,4 @@ function camelCaseRecursive(obj) {
3032
});
3133
}
3234

33-
module.exports = camelCaseRecursive;
34-
35-
36-
var anotherCamelWithTheHump = camelCaseRecursive({
37-
'test-1': 123,
38-
'test-Two': [{
39-
'test-three': {
40-
'test-FOUR': [{'test-five':[{'test-six':{'test-seven':[1,4,[1,2,'3','four', 'five-one']]}}]}]
41-
}
42-
}]
43-
});
44-
45-
console.log(JSON.stringify(anotherCamelWithTheHump));
35+
module.exports = camelCaseRecursive;

package.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Adaptation of camelcase-keys but recursive. ",
55
"main": "index.js",
66
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
7+
"test": "mocha"
88
},
99
"keywords": [
1010
"camelcase",
@@ -14,12 +14,20 @@
1414
"camelcase-keys",
1515
"snake-case"
1616
],
17-
"author": "mike james",
18-
"license": "ISC",
17+
"author": {
18+
"name": "Mike James",
19+
"email": "m@mikejam.es",
20+
"url": "http://mikejam.es"
21+
},
22+
"license": "MIT",
1923
"dependencies": {
2024
"camelcase": "^1.0.2",
2125
"isarray": "0.0.1",
2226
"lodash": "^3.1.0",
2327
"map-obj": "^1.0.0"
28+
},
29+
"devDependencies": {
30+
"chai": "^2.1.1",
31+
"pre-commit": "^1.0.6"
2432
}
2533
}

test/index.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
'use strict';
2+
3+
var expect = require('chai').expect;
4+
5+
var CamelCaseKeysRecursive = require('../');
6+
7+
describe('Nested keys within arrays and objects are camelCased', function() {
8+
9+
it('Should camelCase all Snake keys', function() {
10+
11+
var anotherCamelWithTheHump = CamelCaseKeysRecursive({
12+
'test-1': 123,
13+
'test-Two': [{
14+
'test-three': {
15+
'test-FOUR': [{
16+
'test-five': [{
17+
'test-six': {
18+
'test-seven': [1, 4, [1, 2, '3', 'four', 'five-one']]
19+
}
20+
}]
21+
}]
22+
}
23+
}]
24+
});
25+
26+
expect(anotherCamelWithTheHump).deep.equals({
27+
test1: 123,
28+
testTwo: [{
29+
testThree: {
30+
testFour: [{
31+
testFive: [{
32+
testSix: {
33+
testSeven: [1, 4, [1, 2, '3', 'four', 'five-one']]
34+
}
35+
}]
36+
}]
37+
}
38+
}]
39+
});
40+
41+
});
42+
43+
});

0 commit comments

Comments
 (0)