@@ -45,5 +45,40 @@ describe('query-stringifier', function () {
4545 expect ( parsed ) . to . have . property ( 'foo' , 'bar' ) ;
4646 expect ( parsed ) . to . have . property ( 'thing' , 'thung' ) ;
4747 } ) ;
48+ it ( 'converts an query string with arrays' , function ( ) {
49+ var parsed = qs . parse ( '&arr[]=1&arr[]=2&arr[]=3' ) ;
50+
51+ expect ( parsed ) . to . be . an ( 'object' ) ;
52+ expect ( parsed ) . to . have . keys ( [ 'arr' ] ) ;
53+ expect ( parsed ) . to . deep . equal ( { arr : [ '1' , '2' , '3' ] } ) ;
54+ } ) ;
55+ it ( 'converts an query string with arrays and indexes' , function ( ) {
56+ var parsed = qs . parse ( '&arr[2]=1&arr[0]=2&arr[1]=3' ) ;
57+
58+ expect ( parsed ) . to . be . an ( 'object' ) ;
59+ expect ( parsed ) . to . have . keys ( [ 'arr' ] ) ;
60+ expect ( parsed ) . to . deep . equal ( { arr : [ '2' , '3' , '1' ] } ) ;
61+ } ) ;
4862 } ) ;
63+
64+ describe ( '#extract' , function ( ) {
65+ it ( 'exract the query string of the url' , function ( ) {
66+ var url = 'www.dummyurl.com?firstqueryparam=first&secondqueryparam=second' ;
67+ var result = qs . extract ( url ) ;
68+
69+ expect ( result ) . to . equal ( 'firstqueryparam=first&secondqueryparam=second' ) ;
70+ } ) ;
71+ } ) ;
72+
73+ describe ( '#extract/#parse' , function ( ) {
74+ it ( 'extract the query string of the url and parses it' , function ( ) {
75+ var url = 'www.dummyurl.com?firstqueryparam=first&secondqueryparam=second' ;
76+ var result = qs . parse ( qs . extract ( url ) ) ;
77+
78+ expect ( result ) . to . be . an ( 'object' ) ;
79+ expect ( result ) . to . have . property ( 'firstqueryparam' , 'first' ) ;
80+ expect ( result ) . to . have . property ( 'secondqueryparam' , 'second' ) ;
81+ } ) ;
82+ } ) ;
83+
4984} ) ;
0 commit comments