Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eliottvincent committed Apr 29, 2024
1 parent cfbf618 commit b25b029
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ var __search = function(object, path, currentPath = [], results = []) {
return results;
}

// Extract and remove first path' part
var _part = path[0],
_path = path.slice(1);

Expand Down
8 changes: 6 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var DEFAULT_VALUE = "four";

module.exports = {
testGet: function(test) {
test.expect(41);
test.expect(42);

var actual = src.get;
var message = "get should be defined."
Expand Down Expand Up @@ -71,6 +71,10 @@ module.exports = {
{$d: true, path: "a.b", value: OBJECT.a.b},
{$d: true, path: "a.c", value: OBJECT.a.c}
]],
[OBJECT, "*.*.hello", [
{$d: true, path: "a.b.hello", value: OBJECT.a.b.hello},
{$d: true, path: "a.c.hello", value: OBJECT.a.c.hello}
]],
[OBJECT, "*.two", [
{$d: true, path: "a.two", value: OBJECT.a.two},
]],
Expand All @@ -90,7 +94,7 @@ module.exports = {
]],
[OBJECT, "a.*.hello", [
{$d: true, path: "a.b.hello", value: OBJECT.a.b.hello},
{$d: true, path: "a.c.hello", value: OBJECT.a.c.hello},
{$d: true, path: "a.c.hello", value: OBJECT.a.c.hello}
]],
[OBJECT, "a.*.hello.unexistingKey", undefined],
[OBJECT, "a.c.hello.*", undefined]
Expand Down

0 comments on commit b25b029

Please sign in to comment.