@@ -87,6 +87,11 @@ describe('$location', function() {
87
87
expect ( url . absUrl ( ) ) . toBe ( 'http://www.domain.com:9877/new/path?search=a&b=c&d#hash' ) ;
88
88
} ) ;
89
89
90
+ it ( 'path() should not break on numeric values' , function ( ) {
91
+ url . path ( 1 ) ;
92
+ expect ( url . path ( ) ) . toBe ( '/1' ) ;
93
+ expect ( url . absUrl ( ) ) . toBe ( 'http://www.domain.com:9877/1?search=a&b=c&d#hash' ) ;
94
+ } ) ;
90
95
91
96
it ( 'search() should accept string' , function ( ) {
92
97
url . search ( 'x=y&c' ) ;
@@ -127,6 +132,13 @@ describe('$location', function() {
127
132
} ) ;
128
133
129
134
135
+ it ( 'search() should accept numeric keys' , function ( ) {
136
+ url . search ( { 1 : 'one' , 2 : 'two' } ) ;
137
+ expect ( url . search ( ) ) . toEqual ( { '1' : 'one' , '2' : 'two' } ) ;
138
+ expect ( url . absUrl ( ) ) . toBe ( 'http://www.domain.com:9877/path/b?1=one&2=two#hash' ) ;
139
+ } ) ;
140
+
141
+
130
142
it ( 'search() should handle multiple value' , function ( ) {
131
143
url . search ( 'a&b' ) ;
132
144
expect ( url . search ( ) ) . toEqual ( { a : true , b : true } ) ;
@@ -143,6 +155,8 @@ describe('$location', function() {
143
155
it ( 'search() should handle single value' , function ( ) {
144
156
url . search ( 'ignore' ) ;
145
157
expect ( url . search ( ) ) . toEqual ( { ignore : true } ) ;
158
+ url . search ( 1 ) ;
159
+ expect ( url . search ( ) ) . toEqual ( { 1 : true } ) ;
146
160
} ) ;
147
161
148
162
@@ -163,6 +177,13 @@ describe('$location', function() {
163
177
} ) ;
164
178
165
179
180
+ it ( 'hash() should accept numeric parameter' , function ( ) {
181
+ url . hash ( 5 ) ;
182
+ expect ( url . hash ( ) ) . toBe ( '5' ) ;
183
+ expect ( url . absUrl ( ) ) . toBe ( 'http://www.domain.com:9877/path/b?search=a&b=c&d#5' ) ;
184
+ } ) ;
185
+
186
+
166
187
it ( 'url() should change the path, search and hash' , function ( ) {
167
188
url . url ( '/some/path?a=b&c=d#hhh' ) ;
168
189
expect ( url . url ( ) ) . toBe ( '/some/path?a=b&c=d#hhh' ) ;
0 commit comments