@@ -203,6 +203,7 @@ describe("Scope", () => {
203
203
. select ( { pets : [ "type" ] } )
204
204
. selectExtra ( { people : [ "net_worth" ] } )
205
205
. stats ( { total : "count" } )
206
+ . extraParams ( { foo : "bar" } )
206
207
. includes ( { a : [ "b" , { c : "d" } ] } )
207
208
const qp = scope . asQueryParams ( )
208
209
@@ -226,6 +227,7 @@ describe("Scope", () => {
226
227
stats : {
227
228
total : "count"
228
229
} ,
230
+ foo : "bar" ,
229
231
include : "a.b,a.c.d"
230
232
} )
231
233
} )
@@ -259,6 +261,23 @@ describe("Scope", () => {
259
261
expect ( scope . toQueryParams ( ) ) . to . eq ( undefined )
260
262
} )
261
263
} )
264
+
265
+ describe ( "when arbitrary query params added" , ( ) => {
266
+ it ( "adds to the param string" , ( ) => {
267
+ scope = scope . extraParams ( { foo : "bar" , bar : "baz" } )
268
+ expect ( ( < string > scope . toQueryParams ( ) ) ) . to . eq ( "foo=bar&bar=baz" )
269
+ } )
270
+
271
+ it ( "casts arrays correctly" , ( ) => {
272
+ scope = scope . extraParams ( { foo : "bar,baz" } )
273
+ expect ( ( < string > scope . toQueryParams ( ) ) ) . to . eq ( "foo=bar,baz" )
274
+ } )
275
+
276
+ it ( "casts objects correctly" , ( ) => {
277
+ scope = scope . extraParams ( { foo : { bar : "baz" } } )
278
+ expect ( ( < string > scope . toQueryParams ( ) ) ) . to . eq ( "foo[bar]=baz" )
279
+ } )
280
+ } )
262
281
} )
263
282
264
283
describe ( "#copy" , ( ) => {
0 commit comments