mirror of
https://github.com/fluencelabs/jsonpath
synced 2025-04-25 01:12:17 +00:00
array range with step - js unit test
This commit is contained in:
parent
964e0c00f5
commit
a72a13117e
@ -426,6 +426,55 @@ describe('filter test', () => {
|
||||
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();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('SelectorMut test', () => {
|
||||
|
@ -426,6 +426,55 @@ describe('filter test', () => {
|
||||
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();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('SelectorMut test', () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user