@@ -36,16 +36,16 @@ const scoresData = [
36
36
37
37
describe ( 'jsonquery' , ( ) => {
38
38
describe ( 'prop' , ( ) => {
39
- test ( 'should get a path with brackets ' , ( ) => {
39
+ test ( 'should get a path with a single property as string ' , ( ) => {
40
40
expect ( jsonquery ( { name : 'Joe' } , [ 'get' , 'name' ] ) ) . toEqual ( 'Joe' )
41
41
} )
42
42
43
- test ( 'should get a nested path as array' , ( ) => {
44
- expect ( jsonquery ( { user : { name : 'Joe' } } , [ 'get' , [ 'user' , 'name' ] ] ) ) . toEqual ( 'Joe' )
43
+ test ( 'should get a path with a single property as array' , ( ) => {
44
+ expect ( jsonquery ( { name : 'Joe' } , [ 'get' , [ 'name' ] ] ) ) . toEqual ( 'Joe' )
45
45
} )
46
46
47
- test ( 'should get a nested path as arguments ' , ( ) => {
48
- expect ( jsonquery ( { user : { name : 'Joe' } } , [ 'get' , 'user' , 'name' ] ) ) . toEqual ( 'Joe' )
47
+ test ( 'should get a nested path as array ' , ( ) => {
48
+ expect ( jsonquery ( { user : { name : 'Joe' } } , [ 'get' , [ 'user' , 'name' ] ] ) ) . toEqual ( 'Joe' )
49
49
} )
50
50
51
51
test ( 'should return undefined in case of a non existing path' , ( ) => {
@@ -461,7 +461,7 @@ describe('jsonquery', () => {
461
461
} )
462
462
463
463
test ( 'should sort nested data' , ( ) => {
464
- expect ( jsonquery ( nestedData , [ 'sort' , [ 'get' , 'address' , 'city' ] ] ) ) . toEqual ( [
464
+ expect ( jsonquery ( nestedData , [ 'sort' , [ 'get' , [ 'address' , 'city' ] ] ] ) ) . toEqual ( [
465
465
{ name : 'Emily' , age : 19 , address : { city : 'Atlanta' } } ,
466
466
{ name : 'Kevin' , age : 19 , address : { city : 'Atlanta' } } ,
467
467
{ name : 'Michelle' , age : 27 , address : { city : 'Los Angeles' } } ,
@@ -596,7 +596,7 @@ describe('jsonquery', () => {
596
596
} )
597
597
598
598
test ( 'should get nested data from an array with objects' , ( ) => {
599
- expect ( jsonquery ( nestedData , [ 'map' , [ 'get' , 'address' , 'city' ] ] ) ) . toEqual ( [
599
+ expect ( jsonquery ( nestedData , [ 'map' , [ 'get' , [ 'address' , 'city' ] ] ] ) ) . toEqual ( [
600
600
'New York' ,
601
601
'Atlanta' ,
602
602
'New York' ,
@@ -670,8 +670,8 @@ describe('jsonquery', () => {
670
670
expect ( jsonquery ( data , [ 'not' , 2 ] ) ) . toEqual ( false )
671
671
expect ( jsonquery ( { a : false } , [ 'not' , [ 'get' , 'a' ] ] ) ) . toEqual ( true )
672
672
expect ( jsonquery ( { a : true } , [ 'not' , [ 'get' , 'a' ] ] ) ) . toEqual ( false )
673
- expect ( jsonquery ( { nested : { a : false } } , [ 'not' , [ 'get' , 'nested' , 'a' ] ] ) ) . toEqual ( true )
674
- expect ( jsonquery ( { nested : { a : true } } , [ 'not' , [ 'get' , 'nested' , 'a' ] ] ) ) . toEqual ( false )
673
+ expect ( jsonquery ( { nested : { a : false } } , [ 'not' , [ 'get' , [ 'nested' , 'a' ] ] ] ) ) . toEqual ( true )
674
+ expect ( jsonquery ( { nested : { a : true } } , [ 'not' , [ 'get' , [ 'nested' , 'a' ] ] ] ) ) . toEqual ( false )
675
675
676
676
expect ( jsonquery ( data , [ 'filter' , [ 'not' , [ 'eq' , [ 'get' , 'city' ] , 'New York' ] ] ] ) ) . toEqual ( [
677
677
{ name : 'Emily' , age : 19 , city : 'Atlanta' } ,
0 commit comments