@@ -97,42 +97,52 @@ test('stringify()', function (t) {
97
97
} ) ;
98
98
99
99
t . test ( 'stringifies a nested array value' , function ( st ) {
100
- st . equal ( qs . stringify ( { a : { b : [ 'c' , 'd' ] } } , { arrayFormat : 'indices' } ) , 'a%5Bb%5D%5B0%5D=c&a%5Bb%5D%5B1%5D=d' ) ;
101
- st . equal ( qs . stringify ( { a : { b : [ 'c' , 'd' ] } } , { arrayFormat : 'brackets' } ) , 'a%5Bb%5D%5B%5D=c&a%5Bb%5D%5B%5D=d' ) ;
102
- st . equal ( qs . stringify ( { a : { b : [ 'c' , 'd' ] } } , { arrayFormat : 'comma' } ) , 'a%5Bb%5D=c%2Cd' ) ; // a[b]=c,d
103
- st . equal ( qs . stringify ( { a : { b : [ 'c' , 'd' ] } } ) , 'a%5Bb%5D%5B0%5D=c&a%5Bb%5D%5B1%5D=d' ) ;
100
+ st . equal ( qs . stringify ( { a : { b : [ 'c' , 'd' ] } } , { encodeValuesOnly : true , arrayFormat : 'indices' } ) , 'a[b][0]=c&a[b][1]=d' ) ;
101
+ st . equal ( qs . stringify ( { a : { b : [ 'c' , 'd' ] } } , { encodeValuesOnly : true , arrayFormat : 'brackets' } ) , 'a[b][]=c&a[b][]=d' ) ;
102
+ st . equal ( qs . stringify ( { a : { b : [ 'c' , 'd' ] } } , { encodeValuesOnly : true , arrayFormat : 'comma' } ) , 'a[b]=c%2Cd' ) ;
103
+ st . equal ( qs . stringify ( { a : { b : [ 'c' , 'd' ] } } , { encodeValuesOnly : true , arrayFormat : 'comma' } ) , 'a[b]=c,d' , '(pending issue #378)' , { skip : true } ) ;
104
+ st . equal ( qs . stringify ( { a : { b : [ 'c' , 'd' ] } } , { encodeValuesOnly : true } ) , 'a[b][0]=c&a[b][1]=d' ) ;
104
105
st . end ( ) ;
105
106
} ) ;
106
107
107
108
t . test ( 'stringifies a nested array value with dots notation' , function ( st ) {
108
109
st . equal (
109
110
qs . stringify (
110
111
{ a : { b : [ 'c' , 'd' ] } } ,
111
- { allowDots : true , encode : false , arrayFormat : 'indices' }
112
+ { allowDots : true , encodeValuesOnly : true , arrayFormat : 'indices' }
112
113
) ,
113
114
'a.b[0]=c&a.b[1]=d' ,
114
115
'indices: stringifies with dots + indices'
115
116
) ;
116
117
st . equal (
117
118
qs . stringify (
118
119
{ a : { b : [ 'c' , 'd' ] } } ,
119
- { allowDots : true , encode : false , arrayFormat : 'brackets' }
120
+ { allowDots : true , encodeValuesOnly : true , arrayFormat : 'brackets' }
120
121
) ,
121
122
'a.b[]=c&a.b[]=d' ,
122
123
'brackets: stringifies with dots + brackets'
123
124
) ;
124
125
st . equal (
125
126
qs . stringify (
126
127
{ a : { b : [ 'c' , 'd' ] } } ,
127
- { allowDots : true , encode : false , arrayFormat : 'comma' }
128
+ { allowDots : true , encodeValuesOnly : true , arrayFormat : 'comma' }
128
129
) ,
129
- 'a.b=c,d ' ,
130
+ 'a.b=c%2Cd ' ,
130
131
'comma: stringifies with dots + comma'
131
132
) ;
132
133
st . equal (
133
134
qs . stringify (
134
135
{ a : { b : [ 'c' , 'd' ] } } ,
135
- { allowDots : true , encode : false }
136
+ { allowDots : true , encodeValuesOnly : true , arrayFormat : 'comma' }
137
+ ) ,
138
+ 'a.b=c,d' ,
139
+ 'comma: stringifies with dots + comma (pending issue #378)' ,
140
+ { skip : true }
141
+ ) ;
142
+ st . equal (
143
+ qs . stringify (
144
+ { a : { b : [ 'c' , 'd' ] } } ,
145
+ { allowDots : true , encodeValuesOnly : true }
136
146
) ,
137
147
'a.b[0]=c&a.b[1]=d' ,
138
148
'default: stringifies with dots + indices'
@@ -180,17 +190,23 @@ test('stringify()', function (t) {
180
190
181
191
t . test ( 'stringifies an array with mixed objects and primitives' , function ( st ) {
182
192
st . equal (
183
- qs . stringify ( { a : [ { b : 1 } , 2 , 3 ] } , { encode : false , arrayFormat : 'indices' } ) ,
193
+ qs . stringify ( { a : [ { b : 1 } , 2 , 3 ] } , { encodeValuesOnly : true , arrayFormat : 'indices' } ) ,
184
194
'a[0][b]=1&a[1]=2&a[2]=3' ,
185
195
'indices => indices'
186
196
) ;
187
197
st . equal (
188
- qs . stringify ( { a : [ { b : 1 } , 2 , 3 ] } , { encode : false , arrayFormat : 'brackets' } ) ,
198
+ qs . stringify ( { a : [ { b : 1 } , 2 , 3 ] } , { encodeValuesOnly : true , arrayFormat : 'brackets' } ) ,
189
199
'a[][b]=1&a[]=2&a[]=3' ,
190
200
'brackets => brackets'
191
201
) ;
192
202
st . equal (
193
- qs . stringify ( { a : [ { b : 1 } , 2 , 3 ] } , { encode : false } ) ,
203
+ qs . stringify ( { a : [ { b : 1 } , 2 , 3 ] } , { encodeValuesOnly : true , arrayFormat : 'comma' } ) ,
204
+ '???' ,
205
+ 'brackets => brackets (pending issue #378)' ,
206
+ { skip : true }
207
+ ) ;
208
+ st . equal (
209
+ qs . stringify ( { a : [ { b : 1 } , 2 , 3 ] } , { encodeValuesOnly : true } ) ,
194
210
'a[0][b]=1&a[1]=2&a[2]=3' ,
195
211
'default => indices'
196
212
) ;
0 commit comments