Skip to content

Commit

Permalink
jsonpath-rs unit test for 0.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
freestrings committed Jun 19, 2019
1 parent fff0e86 commit 488e0b4
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 84 deletions.
4 changes: 2 additions & 2 deletions nodejs/native/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jsonpath4nodejs"
version = "0.2.0"
version = "0.2.2"
authors = ["Changseok Han <[email protected]>"]
description = "jsonpath_lib bindings for nodejs"
keywords = ["library", "jsonpath", "json", "nodejs"]
Expand All @@ -14,7 +14,7 @@ exclude = ["artifacts.json", "index.node"]
neon-build = "0.2.0"

[dependencies]
jsonpath_lib = "0.2.0"
jsonpath_lib = "0.2.2"
#jsonpath_lib = { path = "../../" }
neon = "0.2.0"
neon-serde = "0.1.1"
Expand Down
2 changes: 1 addition & 1 deletion nodejs/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 nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsonpath-rs",
"version": "0.2.0",
"version": "0.2.2",
"description": "It is JsonPath implementation. The core implementation is written in Rust",
"author": "Changseok Han <[email protected]>",
"license": "MIT",
Expand Down
160 changes: 80 additions & 80 deletions nodejs/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,78 +413,78 @@ describe('filter test', () => {
}
});

// it('escaped single quote notation', (done) => {
// let result = jsonpath.select({"single'quote":"value"}, "$['single\\'quote']");
// if (JSON.stringify(result) === JSON.stringify(["value"])) {
// done();
// }
// });
//
// it('escaped double quote notation', (done) => {
// let result = jsonpath.select({"single\"quote":"value"}, "$['single\"quote']");
// if (JSON.stringify(result) === JSON.stringify(["value"])) {
// done();
// }
// });
//
// it('array range with step - $[::]', (done) => {
// let result = jsonpath.select(["first", "second", "third", "forth", "fifth"], "$[::]");
// if (JSON.stringify(result) === JSON.stringify(["first", "second", "third", "forth", "fifth"])) {
// done();
// }
// });
//
// it('array range with step - $[::2]', (done) => {
// let result = jsonpath.select(["first", "second", "third", "forth", "fifth"], "$[::2]");
// if (JSON.stringify(result) === JSON.stringify(["first", "third", "fifth"])) {
// done();
// }
// });
//
// it('array range with step - $[1: :]', (done) => {
// let result = jsonpath.select(["first", "second", "third", "forth", "fifth"], "$[1: :]");
// if (JSON.stringify(result) === JSON.stringify(["second", "third", "forth", "fifth"])) {
// done();
// }
// });
//
// it('array range with step - $[1:2:]', (done) => {
// let result = jsonpath.select(["first", "second", "third", "forth", "fifth"], "$[1:2:]");
// if (JSON.stringify(result) === JSON.stringify(["second"])) {
// done();
// }
// });
//
// it('array range with step - $[1::2]', (done) => {
// let result = jsonpath.select(["first", "second", "third", "forth", "fifth"], "$[1::2]");
// if (JSON.stringify(result) === JSON.stringify(["second", "forth"])) {
// done();
// }
// });
//
// it('array range with step - $[0:3:1]', (done) => {
// let result = jsonpath.select(["first", "second", "third", "forth", "fifth"], "$[0:3:1]");
// if (JSON.stringify(result) === JSON.stringify(["first", "second", "third"])) {
// done();
// }
// });
//
// it('array range with step - $[0:3:2]', (done) => {
// let result = jsonpath.select(["first", "second", "third", "forth", "fifth"], "$[0:3:2]");
// if (JSON.stringify(result) === JSON.stringify(["first", "third"])) {
// done();
// }
// });
//
// it('array keys', (done) => {
// let result = jsonpath.select({
// "key1": "value1",
// "key2": 2
// }, "$['key1', 'key2']");
// if (JSON.stringify(result) === JSON.stringify(["value1", 2])) {
// done();
// }
// });
it('escaped single quote notation', (done) => {
let result = jsonpath.select({"single'quote":"value"}, "$['single\\'quote']");
if (JSON.stringify(result) === JSON.stringify(["value"])) {
done();
}
});

it('escaped double quote notation', (done) => {
let result = jsonpath.select({"single\"quote":"value"}, "$['single\"quote']");
if (JSON.stringify(result) === JSON.stringify(["value"])) {
done();
}
});

it('array range with step - $[::]', (done) => {
let result = jsonpath.select(["first", "second", "third", "forth", "fifth"], "$[::]");
if (JSON.stringify(result) === JSON.stringify(["first", "second", "third", "forth", "fifth"])) {
done();
}
});

it('array range with step - $[::2]', (done) => {
let result = jsonpath.select(["first", "second", "third", "forth", "fifth"], "$[::2]");
if (JSON.stringify(result) === JSON.stringify(["first", "third", "fifth"])) {
done();
}
});

it('array range with step - $[1: :]', (done) => {
let result = jsonpath.select(["first", "second", "third", "forth", "fifth"], "$[1: :]");
if (JSON.stringify(result) === JSON.stringify(["second", "third", "forth", "fifth"])) {
done();
}
});

it('array range with step - $[1:2:]', (done) => {
let result = jsonpath.select(["first", "second", "third", "forth", "fifth"], "$[1:2:]");
if (JSON.stringify(result) === JSON.stringify(["second"])) {
done();
}
});

it('array range with step - $[1::2]', (done) => {
let result = jsonpath.select(["first", "second", "third", "forth", "fifth"], "$[1::2]");
if (JSON.stringify(result) === JSON.stringify(["second", "forth"])) {
done();
}
});

it('array range with step - $[0:3:1]', (done) => {
let result = jsonpath.select(["first", "second", "third", "forth", "fifth"], "$[0:3:1]");
if (JSON.stringify(result) === JSON.stringify(["first", "second", "third"])) {
done();
}
});

it('array range with step - $[0:3:2]', (done) => {
let result = jsonpath.select(["first", "second", "third", "forth", "fifth"], "$[0:3:2]");
if (JSON.stringify(result) === JSON.stringify(["first", "third"])) {
done();
}
});

it('array keys', (done) => {
let result = jsonpath.select({
"key1": "value1",
"key2": 2
}, "$['key1', 'key2']");
if (JSON.stringify(result) === JSON.stringify(["value1", 2])) {
done();
}
});
});

describe('SelectorMut test', () => {
Expand Down Expand Up @@ -886,11 +886,11 @@ describe('README test', () => {
});
});

// describe('ISSUE test', () => {
// it('Results do not match other implementations #6', (done) => {
// let result = jsonpath.select(["first", "second"], "$[:]");
// if (JSON.stringify(result) === JSON.stringify(["first", "second"])) {
// done();
// }
// });
// });
describe('ISSUE test', () => {
it('Results do not match other implementations #6', (done) => {
let result = jsonpath.select(["first", "second"], "$[:]");
if (JSON.stringify(result) === JSON.stringify(["first", "second"])) {
done();
}
});
});

0 comments on commit 488e0b4

Please sign in to comment.