find-ancestors
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -119,3 +119,3 @@ 'use strict'; | ||
if (!nodes) { | ||
if (!nodes.length) { | ||
return result; | ||
@@ -122,0 +122,0 @@ } |
{ | ||
"name": "find-ancestors", | ||
"version": "1.0.2", | ||
"description": "Get all ancestors elements of a nested node", | ||
"version": "1.0.3", | ||
"description": "Recursively find and return a nested node and all its ancestors (parents) from a nested data structure (i.e. tree)", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -8,2 +8,5 @@ 'use strict'; | ||
var current; | ||
var predicate = function(item) { | ||
return item.id === 4; | ||
}; | ||
@@ -14,5 +17,2 @@ describe('find-ancestors', function() { | ||
it('should return a matched object from plain arrays & generate uniques meta IDs', function() { | ||
var predicate = function(item) { | ||
return item.id === 4; | ||
}; | ||
@@ -23,2 +23,4 @@ var custom = [{ id: 1}, { id: 4}]; | ||
expect(current).to.be.deep.equal([{ id: 4, __id: 2 }]); | ||
// Ensure that findAncestors doesn't modify passed object | ||
expect(initial).to.be.deep.equal(initial); | ||
}); | ||
@@ -49,6 +51,7 @@ | ||
.to.throw(/should be a function/); | ||
expect(findAncestors.bind(null, { data: [], predicate: predicate })) | ||
.not.to.throw(TypeError); | ||
}); | ||
}); | ||
}); |
8853
224