@@ -36,6 +36,14 @@ describe('navigation', function () {
3636 template : '<div>{{$ctrl.number}}</div>' ,
3737 controller : function ( ) { this . number = 'three' }
3838 } ) ;
39+ registerComponent ( 'getParams' , {
40+ template : '<div>{{$ctrl.params.x}}</div>' ,
41+ controller : function ( ) {
42+ this . $routerOnActivate = function ( next ) {
43+ this . params = next . params ;
44+ } ;
45+ }
46+ } )
3947 } ) ;
4048
4149 it ( 'should work in a simple case' , function ( ) {
@@ -186,6 +194,21 @@ describe('navigation', function () {
186194 } ) ) ;
187195
188196
197+ it ( 'should pass through query terms to the location' , inject ( function ( $location ) {
198+ $router . config ( [
199+ { path : '/user' , component : 'userCmp' }
200+ ] ) ;
201+
202+ compile ( '<div ng-outlet></div>' ) ;
203+
204+ $router . navigateByUrl ( '/user?x=y' ) ;
205+ $rootScope . $digest ( ) ;
206+
207+ expect ( $location . path ( ) ) . toBe ( '/user' ) ;
208+ expect ( $location . search ( ) ) . toEqual ( { x : 'y' } ) ;
209+ } ) ) ;
210+
211+
189212 it ( 'should change location to the canonical route' , inject ( function ( $location ) {
190213 compile ( '<div ng-outlet></div>' ) ;
191214
@@ -245,6 +268,19 @@ describe('navigation', function () {
245268 } ) ) ;
246269
247270
271+ it ( 'should navigate when the location query changes' , inject ( function ( $location ) {
272+ $router . config ( [
273+ { path : '/get/params' , component : 'getParams' }
274+ ] ) ;
275+ compile ( '<div ng-outlet></div>' ) ;
276+
277+ $location . url ( '/get/params?x=y' ) ;
278+ $rootScope . $digest ( ) ;
279+
280+ expect ( elt . text ( ) ) . toBe ( 'y' ) ;
281+ } ) ) ;
282+
283+
248284 it ( 'should expose a "navigating" property on $router' , inject ( function ( $q ) {
249285 var defer ;
250286 registerDirective ( 'pendingActivate' , {
0 commit comments