@@ -2364,17 +2364,41 @@ describe('$http param serializers', function() {
2364
2364
expect ( decodeURIComponent ( jqrSer ( { a : 'b' , foo : [ 'bar' , 'baz' ] } ) ) ) . toEqual ( 'a=b&foo[]=bar&foo[]=baz' ) ;
2365
2365
} ) ;
2366
2366
2367
+ it ( 'should serialize arrays with functions' , function ( ) {
2368
+ expect ( jqrSer ( { foo : [ valueFn ( 'bar' ) ] } ) ) . toEqual ( 'foo%5B%5D=bar' ) ; // foo[]=bar
2369
+ } ) ;
2370
+
2371
+ it ( 'should serialize arrays with functions inside objects' , function ( ) {
2372
+ expect ( jqrSer ( { foo : { bar : [ valueFn ( 'baz' ) ] } } ) ) . toEqual ( 'foo%5Bbar%5D%5B%5D=baz' ) ; // foo[bar][]=baz
2373
+ } ) ;
2374
+
2367
2375
it ( 'should serialize objects by repeating param name with [key] suffix' , function ( ) {
2368
2376
expect ( jqrSer ( { a : 'b' , foo : { 'bar' : 'barv' , 'baz' : 'bazv' } } ) ) . toEqual ( 'a=b&foo%5Bbar%5D=barv&foo%5Bbaz%5D=bazv' ) ;
2369
2377
//a=b&foo[bar]=barv&foo[baz]=bazv
2370
2378
} ) ;
2371
2379
2380
+ it ( 'should serialize objects with function properties' , function ( ) {
2381
+ expect ( jqrSer ( { a : valueFn ( 'b' ) } ) ) . toEqual ( 'a=b' ) ;
2382
+ } ) ;
2383
+
2384
+ it ( 'should serialize objects with function properties returning an object' , function ( ) {
2385
+ expect ( jqrSer ( { a : valueFn ( { b : 'c' } ) } ) ) . toEqual ( 'a=%7B%22b%22:%22c%22%7D' ) ; //a={"b":"c"}
2386
+ } ) ;
2387
+
2372
2388
it ( 'should serialize nested objects by repeating param name with [key] suffix' , function ( ) {
2373
2389
expect ( jqrSer ( { a : [ 'b' , { c : 'd' } ] , e : { f : 'g' , 'h' : [ 'i' , 'j' ] } } ) ) . toEqual (
2374
2390
'a%5B%5D=b&a%5B1%5D%5Bc%5D=d&e%5Bf%5D=g&e%5Bh%5D%5B%5D=i&e%5Bh%5D%5B%5D=j' ) ;
2375
2391
//a[]=b&a[1][c]=d&e[f]=g&e[h][]=i&e[h][]=j
2376
2392
} ) ;
2377
2393
2394
+ it ( 'should serialize nested objects with function properties' , function ( ) {
2395
+ expect ( jqrSer ( { foo : { bar : valueFn ( 'barv' ) } } ) ) . toEqual ( 'foo%5Bbar%5D=barv' ) ; //foo[bar]=barv
2396
+ } ) ;
2397
+
2398
+ it ( 'should serialize nested objects with function properties returning an object' , function ( ) {
2399
+ expect ( jqrSer ( { foo : { bar : valueFn ( { bav : 'barv' } ) } } ) ) . toEqual ( 'foo%5Bbar%5D=%7B%22bav%22:%22barv%22%7D' ) ; //foo[bar]={"bav":"barv"}
2400
+ } ) ;
2401
+
2378
2402
it ( 'should serialize objects inside array elements using their index' , function ( ) {
2379
2403
expect ( jqrSer ( { a : [ 'b' , 'c' ] , d : [ { e : 'f' , g : 'h' } , 'i' , { j : 'k' } ] } ) ) . toEqual (
2380
2404
'a%5B%5D=b&a%5B%5D=c&d%5B0%5D%5Be%5D=f&d%5B0%5D%5Bg%5D=h&d%5B%5D=i&d%5B2%5D%5Bj%5D=k' ) ;
0 commit comments