Skip to content

Commit f6868d4

Browse files
committed
- Testing: Improve coverage
1 parent 82ebc5b commit f6868d4

8 files changed

Lines changed: 27 additions & 6 deletions

dist/index-es.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ var vm = JSONPath.nodeVMSupported ? require('vm') : {
210210
moveToAnotherArray(keys, funcs, function (key) {
211211
return typeof context[key] === 'function';
212212
});
213-
var values = Object.values(context);
213+
var values = keys.map(function (vr, i) {
214+
return context[vr];
215+
});
214216
var funcString = funcs.reduce(function (s, func) {
215217
var fString = context[func].toString();
216218

dist/index-es.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index-es.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index-umd.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,9 @@
216216
moveToAnotherArray(keys, funcs, function (key) {
217217
return typeof context[key] === 'function';
218218
});
219-
var values = Object.values(context);
219+
var values = keys.map(function (vr, i) {
220+
return context[vr];
221+
});
220222
var funcString = funcs.reduce(function (s, func) {
221223
var fString = context[func].toString();
222224

dist/index-umd.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index-umd.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/test.parent-selector.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ checkBuiltInVMAndNodeVM(function (vmType, setBuiltInState) {
3535
assert.deepEqual(result, expected);
3636
});
3737

38+
/*
39+
// Todo: Handle Maximum call stack error getting here
40+
it('parent root', () => {
41+
const jsonSimple = {};
42+
const expected = json.children;
43+
const result = jsonpath({json: jsonSimple, path: '^', flatten: true});
44+
assert.deepEqual(result, expected);
45+
});
46+
*/
47+
3848
it('no such parent', () => {
3949
const result = jsonpath({json, path: 'name^^'});
4050
assert.deepEqual(result, []);

test/test.properties.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,12 @@ checkBuiltInVMAndNodeVM(function (vmType, setBuiltInState) {
3333
result = jsonpath({json, path: "$.datafield[2][(@['@tag'])]", wrap: false});
3434
assert.deepEqual(result, json.datafield[2]['045']);
3535
});
36+
37+
it('At signs within properties (null data)', () => {
38+
const result = jsonpath({json: {
39+
datafield: [null]
40+
}, path: "$.datafield[?(@.tag=='xxx')]", wrap: false});
41+
assert.deepEqual(result, undefined);
42+
});
3643
});
3744
});

0 commit comments

Comments
 (0)