Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Amram authored and flexdinesh committed Mar 7, 2018
1 parent c5f0c86 commit 6588e1b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions test/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,28 @@ describe('Nested Object/Keys Check', () => {
let mockObj = {
nestedArray: [
{ goodKey: 'hello one' },
{ goodKey: 'hello two' }
{ goodKey: 'hello two' },
{ goodKey: 'hello three' },
{ goodKey: 'hello four' },
{ goodKey: 'hello five' },
{ goodKey: 'hello six' },
{ goodKey: 'hello seven' },
{ goodKey: 'hello eight' },
{ goodKey: 'hello nine' },
{ goodKey: 'hello ten' },
{ goodKey: 'hello eleven' },
]
};
assert(getNestedObject(mockObj, 'nestedArray[0].goodKey') === 'hello one');
assert(getNestedObject(mockObj, 'nestedArray[1].goodKey') === 'hello two');
assert(getNestedObject(mockObj, 'nestedArray[10].goodKey') === 'hello eleven');

mockObj = {
nestedArray: ['a', 'b']
nestedArray: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k']
};
assert(getNestedObject(mockObj, 'nestedArray[0]') === 'a');
assert(getNestedObject(mockObj, 'nestedArray[1]') === 'b');
assert(getNestedObject(mockObj, 'nestedArray[10]') === 'k');
});

it('should return undefined when array element in path does not exist', () => {
Expand Down

0 comments on commit 6588e1b

Please sign in to comment.