@@ -2,10 +2,11 @@ describe('Methods', function () {
22 describe ( 'defaults' , function ( ) {
33 it ( 'has defaults' , function ( ) {
44 var defaults = yea . toObject ( ) ;
5- expect ( defaults ) . to . have . keys ( [ 'method' , 'baseUrl' , 'url' , 'query' , 'body' , 'headers' , 'responseTransformers' , 'allowedStatusCode' , 'timeout' , 'prop' , 'polyfills' ] ) ;
5+ expect ( defaults ) . to . have . keys ( [ 'method' , 'baseUrl' , 'url' , 'urlParams' , ' query', 'body' , 'headers' , 'responseTransformers' , 'allowedStatusCode' , 'timeout' , 'prop' , 'polyfills' ] ) ;
66 expect ( defaults . method ) . to . equal ( 'GET' ) ;
77 expect ( defaults . baseUrl ) . to . equal ( '' ) ;
88 expect ( defaults . url ) . to . equal ( '' ) ;
9+ expect ( defaults . urlParams ) . to . deep . equal ( { } ) ;
910 expect ( defaults . query ) . to . equal ( '' ) ;
1011 expect ( defaults . body ) . to . equal ( '' ) ;
1112 expect ( defaults . headers ) . to . deep . equal ( { } ) ;
@@ -127,6 +128,32 @@ describe('Methods', function () {
127128 } ) ;
128129 } ) ;
129130
131+ describe ( '.urlParams' , function ( ) {
132+ it ( 'sets urlParams' , function ( ) {
133+ expect ( yea . urlParams ( { super : 'yes' } ) . toObject ( ) . urlParams ) . to . deep . equal ( { super : 'yes' } ) ;
134+ expect ( yea . urlParams ( { SUPER : 'yes' } ) . toObject ( ) . urlParams ) . to . deep . equal ( { SUPER : 'yes' } ) ;
135+ } ) ;
136+
137+ it ( 'overwrites existing urlParams' , function ( ) {
138+ var req = yea . urlParams ( { super : 'yes' , foo : 'sir' } ) ;
139+ expect ( req . urlParams ( { foo : 'bar' , fresh : 'sure' } ) . toObject ( ) . urlParams ) . to . deep . equal ( { foo : 'bar' , fresh : 'sure' } ) ;
140+ } ) ;
141+
142+ it ( 'leaves no references' , function ( ) {
143+ var urlParams = { super : 'yes' } ;
144+ var req = yea . urlParams ( urlParams ) ;
145+ expect ( req . toObject ( ) . urlParams ) . to . not . equal ( urlParams ) ;
146+ urlParams . super = 'modified' ;
147+ expect ( req . toObject ( ) . urlParams . super ) . to . equal ( 'yes' ) ;
148+ } ) ;
149+
150+ it ( 'is immutable' , function ( ) {
151+ var req = yea . urlParams ( { super : 123 } ) ;
152+ expect ( req ) . to . not . equal ( yea ) ;
153+ expect ( req . constructor ) . to . equal ( yea . constructor ) ;
154+ } ) ;
155+ } ) ;
156+
130157 describe ( '.baseUrl' , function ( ) {
131158 it ( 'sets baseUrl' , function ( ) {
132159 expect ( yea . baseUrl ( 'http://example.com' ) . toObject ( ) . baseUrl ) . to . equal ( 'http://example.com' ) ;
0 commit comments