Skip to content

Commit

Permalink
V1.1.1 (#20)
Browse files Browse the repository at this point in the history
* build: added build, buildOne, buildAll

* chore: updated declaration files

* chore: updated package lock

* fix: resolved issue where it failed to query non existing element from an array

* chore: updated package version

* chore: added set from Map test to settingValues again
  • Loading branch information
JG-1202 authored Dec 26, 2021
1 parent b42b7ae commit fc5b4ea
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog
All notable changes to this project will be documented here.

## [1.1.1] - 2021-12-26
### Changed
- resolved issue where it failed to query non existing element from an array

## [1.1.0] - 2021-12-26
### Added
- build, buildOne, buildAll handlers: sets function output on specified json path
Expand Down
4 changes: 4 additions & 0 deletions ___tests___/index/settingValues.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ describe('Test setting value(s)', () => {
JsonGo.setAll('[{$.bla.foo}].bla.foo', 123);
expect(JsonGo.export()).toStrictEqual(testObject);
});
it('It does not fail when non-existing wildcard is attempted to be set', () => {
const result = JG.set([], 'test[*].test', 8);
expect(result).toStrictEqual([]);
});
});

describe('README examples', () => {
Expand Down
8 changes: 8 additions & 0 deletions ___tests___/resolve.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ describe('Test getAll function', () => {
test([], '[*][*]', []);
test(null, '[*][*]', []);
});
it('Gets wildcard non existing property of an array', () => {
test([], 'test', []);
test([], 'test[*].test', []);
});
it('Gets wildcard non existing property of an object', () => {
test({}, 'test', []);
test({}, 'test[*].test', []);
});
});

describe('Testing JSON equality', () => {
Expand Down
8 changes: 8 additions & 0 deletions ___tests___/resolveOne.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,12 @@ describe('Test get function', () => {
it('Getting falsy value', () => {
test({ test: false }, 'test', false);
});
it('Gets wildcard non existing property of an array', () => {
test([], 'test', undefined);
test([], 'test[*].test', undefined);
});
it('Gets wildcard non existing property of an object', () => {
test({}, 'test', undefined);
test({}, 'test[*].test', undefined);
});
});
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "js-json-go",
"version": "1.1.0",
"version": "1.1.1",
"description": "Retrieves and constructs values from/into JSON objects. Js-JSON-Go is a lightweight library that offers the ability to query JSON objects to obtain data and use the same query format to build JSON objects.",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/services/querier/src/isOperationToGetEnd/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* check if operation is to get end of array
*/
const isOperationToGetEnd = (query) => query[0] && query[0].custom === 'end';
const isOperationToGetEnd = (query) => query && query[0] && query[0].custom === 'end';

module.exports = isOperationToGetEnd;

0 comments on commit fc5b4ea

Please sign in to comment.