Skip to content

Commit

Permalink
hasPath return false for non-object checks (#2825)
Browse files Browse the repository at this point in the history
* hasPath return false for non-object checks

Used to throw an Error for non-object children tests
Added test for object checking if val is an object when testing a path
Added tests testing false is returned for non-objects children tests
Related to github issue #2771

* Linting the file

* Removed change as added to tests
  • Loading branch information
LorneCurrie authored and CrossEye committed May 15, 2019
1 parent 0baeda1 commit c45208e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/hasPath.js
Expand Up @@ -24,6 +24,13 @@ describe('hasPath', function() {
eq(R.hasPath(['undefinedVal'], obj), true);
});

it('return false for a test for a child to a non-object', function() {
eq(R.hasPath(['undefinedVal', 'child', 'grandchild'], obj), false);
eq(R.hasPath(['falseVal', 'child', 'grandchild'], obj), false);
eq(R.hasPath(['nullVal', 'child', 'grandchild'], obj), false);
eq(R.hasPath(['arrayVal', 0, 'child', 'grandchild'], obj), false);
});

it('returns true for existing path with indexes', function() {
eq(R.hasPath(['arrayVal', 0], obj), true);
});
Expand Down

0 comments on commit c45208e

Please sign in to comment.