-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
132 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "array deep bug #10", | ||
"options": { | ||
"useArray": true | ||
}, | ||
"input": { | ||
"a[0]": "A0", | ||
"a[1]": "A1", | ||
"a[2]": "A2", | ||
"a[3].b[0].c[0]": "A3B0C0", | ||
"a[3].b[0].c[1]": "A3B0C1" | ||
}, | ||
"expected": { | ||
"a": [ | ||
"A0", | ||
"A1", | ||
"A2", | ||
{ | ||
"b": [ | ||
{ | ||
"c": [ | ||
"A3B0C0", | ||
"A3B0C1" | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "array deep bug2 #10", | ||
"options": { | ||
"useArray": true | ||
}, | ||
"input": { | ||
"b.0.c.1": "b0c1", | ||
"b.0.c.2": "b0c2" | ||
}, | ||
"expected": { | ||
"b" : [ { | ||
"c" : [ | ||
null, | ||
"b0c1", | ||
"b0c2" | ||
] | ||
}] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "object deep numeric keys", | ||
"options": { | ||
"useArray": false | ||
}, | ||
"input": { | ||
"a[0]": "A0", | ||
"a[1]": "A1", | ||
"a[2]": "A2", | ||
"a[3].b[0].c[0]": "A3B0C0", | ||
"a[3].b[0].c[1]": "A3B0C1" | ||
}, | ||
"expected": { | ||
"a": { | ||
"0": "A0", | ||
"1": "A1", | ||
"2": "A2", | ||
"3": { | ||
"b": { | ||
"0": { | ||
"c": { | ||
"0": "A3B0C0", | ||
"1": "A3B0C1" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "object deep numeric keys 2 #10", | ||
"options": { | ||
"useArray": false | ||
}, | ||
"input": { | ||
"b.0.c.1": "b0c1", | ||
"b.0.c.2": "b0c2" | ||
}, | ||
"expected": { | ||
"b": { | ||
"0": { | ||
"c": { | ||
"1": "b0c1", | ||
"2": "b0c2" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict'; | ||
|
||
require('should'); | ||
var Dot = require('../index'); | ||
|
||
var testData = [ | ||
require('./data/array_deep_bug'), | ||
require('./data/array_deep_bug2'), | ||
require('./data/object_deep_numeric_keys'), | ||
require('./data/object_deep_numeric_keys2') | ||
]; | ||
|
||
describe('Test Data:', function() { | ||
|
||
var dot = new Dot(); | ||
function testIt(test) { | ||
it(test.name, function() { | ||
if (test.options) { | ||
Object.keys(test.options).forEach(function(name) { | ||
dot[name] = test.options[name]; | ||
}); | ||
} | ||
dot.object(test.input); | ||
JSON.stringify(test.input).should.eql(JSON.stringify(test.expected)); | ||
}); | ||
} | ||
|
||
// note with object() it is possible to cleanup, with del it is not. | ||
|
||
testData.forEach(testIt); | ||
}); |