From 72ab35bcebe861ab6d3c1c2312ca819109d2cf8a Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Sun, 7 Feb 2016 22:09:06 +0000 Subject: [PATCH] test(angular1_router): test that location handles query strings See 6698 --- .../test/integration/navigation_spec.js | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/modules/angular1_router/test/integration/navigation_spec.js b/modules/angular1_router/test/integration/navigation_spec.js index a266703270..70bcf2eeee 100644 --- a/modules/angular1_router/test/integration/navigation_spec.js +++ b/modules/angular1_router/test/integration/navigation_spec.js @@ -36,6 +36,14 @@ describe('navigation', function () { template: '
{{$ctrl.number}}
', controller: function () {this.number = 'three'} }); + registerComponent('getParams', { + template: '
{{$ctrl.params.x}}
', + controller: function () { + this.$routerOnActivate = function(next) { + this.params = next.params; + }; + } + }) }); it('should work in a simple case', function () { @@ -186,6 +194,21 @@ describe('navigation', function () { })); + it('should pass through query terms to the location', inject(function ($location) { + $router.config([ + { path: '/user', component: 'userCmp' } + ]); + + compile('
'); + + $router.navigateByUrl('/user?x=y'); + $rootScope.$digest(); + + expect($location.path()).toBe('/user'); + expect($location.search()).toEqual({ x: 'y'}); + })); + + it('should change location to the canonical route', inject(function ($location) { compile('
'); @@ -245,6 +268,19 @@ describe('navigation', function () { })); + it('should navigate when the location query changes', inject(function ($location) { + $router.config([ + { path: '/get/params', component: 'getParams' } + ]); + compile('
'); + + $location.url('/get/params?x=y'); + $rootScope.$digest(); + + expect(elt.text()).toBe('y'); + })); + + it('should expose a "navigating" property on $router', inject(function ($q) { var defer; registerDirective('pendingActivate', {