File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1626,12 +1626,12 @@ test('mapping - map and append full array to existing mapped array', function (t
16261626
16271627 var expect = {
16281628 'thing2' : [
1629- [ { a : 'a1' , b : 'b1' }
1629+ { a : 'a1' , b : 'b1' }
16301630 , { a : 'a2' , b : 'b2' }
1631- , { a : 'a3' , b : 'b3' } ] ,
1632- [ { a : 'a4' , b : 'b4' }
1631+ , { a : 'a3' , b : 'b3' }
1632+ , { a : 'a4' , b : 'b4' }
16331633 , { a : 'a5' , b : 'b5' }
1634- , { a : 'a6' , b : 'b6' } ]
1634+ , { a : 'a6' , b : 'b6' }
16351635 ]
16361636 } ;
16371637
@@ -2173,5 +2173,32 @@ test('Make sure no objects are created without data #48', function (t) {
21732173 t . end ( ) ;
21742174} ) ;
21752175
2176-
2176+ test ( '1 array mapping wraps destination in an unwanted array #49' , function ( t ) {
2177+ const src = {
2178+ foo : [ { bar : 4 } , { bar : 33 } ] ,
2179+ bifoo : [ { bar : 77 } , { bar : 97 } ]
2180+ } ;
2181+ const mapper = {
2182+ "foo[].bar" : "[]+" ,
2183+ "bifoo[].bar" : "[]+"
2184+ }
2185+ var expect = [ 4 , 33 , 77 , 97 ] ;
2186+ var result = om ( src , mapper ) ;
2187+ t . deepEqual ( result , expect ) ;
2188+ t . end ( ) ;
2189+ } ) ;
2190+ test ( '2 array mapping wraps destination in an unwanted array #49' , function ( t ) {
2191+ const src = {
2192+ foo : [ { bar : 4 } , { bar : 33 } ] ,
2193+ bifoo : [ { bar : 77 } , { bar : 97 } ]
2194+ } ;
2195+ const mapper2 = {
2196+ "foo[].bar" : "num[]+" ,
2197+ "bifoo[].bar" : "num[]+"
2198+ }
2199+ var expect = { num : [ 4 , 33 , 77 , 97 ] } ;
2200+ var result = om ( src , mapper2 ) ;
2201+ t . deepEqual ( result , expect ) ;
2202+ t . end ( ) ;
2203+ } ) ;
21772204
You can’t perform that action at this time.
0 commit comments