|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | | -(function () { |
4 | | -// tests based on examples at http://goessner.net/articles/jsonpath/ |
5 | | - |
6 | | -const json = { |
7 | | - "store": { |
8 | | - "book": [{ |
9 | | - "category": "reference", |
10 | | - "author": "Nigel Rees", |
11 | | - "title": "Sayings of the Century", |
12 | | - "price": 8.95 |
13 | | - }, |
14 | | - { |
15 | | - "category": "fiction", |
16 | | - "author": "Evelyn Waugh", |
17 | | - "title": "Sword of Honour", |
18 | | - "price": 12.99 |
19 | | - }, |
20 | | - { |
21 | | - "category": "fiction", |
22 | | - "author": "Herman Melville", |
23 | | - "title": "Moby Dick", |
24 | | - "isbn": "0-553-21311-3", |
25 | | - "price": 8.99 |
26 | | - }, |
27 | | - { |
28 | | - "category": "fiction", |
29 | | - "author": "J. R. R. Tolkien", |
30 | | - "title": "The Lord of the Rings", |
31 | | - "isbn": "0-395-19395-8", |
32 | | - "price": 22.99 |
33 | | - }], |
34 | | - "bicycle": { |
35 | | - "color": "red", |
36 | | - "price": 19.95 |
| 3 | +describe('JSONPath - Examples', function () { |
| 4 | + // tests based on examples at http://goessner.net/articles/jsonpath/ |
| 5 | + const json = { |
| 6 | + "store": { |
| 7 | + "book": [{ |
| 8 | + "category": "reference", |
| 9 | + "author": "Nigel Rees", |
| 10 | + "title": "Sayings of the Century", |
| 11 | + "price": 8.95 |
| 12 | + }, |
| 13 | + { |
| 14 | + "category": "fiction", |
| 15 | + "author": "Evelyn Waugh", |
| 16 | + "title": "Sword of Honour", |
| 17 | + "price": 12.99 |
| 18 | + }, |
| 19 | + { |
| 20 | + "category": "fiction", |
| 21 | + "author": "Herman Melville", |
| 22 | + "title": "Moby Dick", |
| 23 | + "isbn": "0-553-21311-3", |
| 24 | + "price": 8.99 |
| 25 | + }, |
| 26 | + { |
| 27 | + "category": "fiction", |
| 28 | + "author": "J. R. R. Tolkien", |
| 29 | + "title": "The Lord of the Rings", |
| 30 | + "isbn": "0-395-19395-8", |
| 31 | + "price": 22.99 |
| 32 | + }], |
| 33 | + "bicycle": { |
| 34 | + "color": "red", |
| 35 | + "price": 19.95 |
| 36 | + } |
37 | 37 | } |
38 | | - } |
39 | | -}; |
| 38 | + }; |
40 | 39 |
|
41 | | -describe('JSONPath - Examples', function () { |
42 | 40 | it('wildcards (with and without $.)', () => { |
43 | 41 | const books = json.store.book; |
44 | 42 | const expected = [books[0].author, books[1].author, books[2].author, books[3].author]; |
@@ -226,4 +224,3 @@ describe('JSONPath - Examples', function () { |
226 | 224 | assert.deepEqual(expected, result); |
227 | 225 | }); |
228 | 226 | }); |
229 | | -}()); |
0 commit comments