From 48697a2b86dbb12ea8de64cc5fece7caf68b321e Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Mon, 17 Oct 2011 16:56:56 -0700 Subject: refactor(injector): turn scope into a service - turn scope into a $rootScope service. - injector is now a starting point for creating angular application. - added inject() method which wraps jasmine its/beforeEach/afterEach, and which allows configuration and injection of services. - refactor tests to use inject() where possible BREAK: - removed angular.scope() method --- test/service/routeParamsSpec.js | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) (limited to 'test/service/routeParamsSpec.js') diff --git a/test/service/routeParamsSpec.js b/test/service/routeParamsSpec.js index 972e4314..d4088767 100644 --- a/test/service/routeParamsSpec.js +++ b/test/service/routeParamsSpec.js @@ -1,41 +1,16 @@ 'use strict'; describe('$routeParams', function() { - it('should publish the params into a service', function() { - var scope = angular.scope(), - $location = scope.$service('$location'), - $route = scope.$service('$route'), - $routeParams = scope.$service('$routeParams'); - + it('should publish the params into a service', inject(function($rootScope, $route, $location, $routeParams) { $route.when('/foo'); $route.when('/bar/:barId'); $location.path('/foo').search('a=b'); - scope.$digest(); + $rootScope.$digest(); expect($routeParams).toEqual({a:'b'}); $location.path('/bar/123').search('x=abc'); - scope.$digest(); + $rootScope.$digest(); expect($routeParams).toEqual({barId:'123', x:'abc'}); - }); - - - it('should preserve object identity during route reloads', function() { - var scope = angular.scope(), - $location = scope.$service('$location'), - $route = scope.$service('$route'), - $routeParams = scope.$service('$routeParams'), - firstRouteParams = $routeParams; - - $route.when('/foo'); - $route.when('/bar/:barId'); - - $location.path('/foo').search('a=b'); - scope.$digest(); - expect(scope.$service('$routeParams')).toBe(firstRouteParams); - - $location.path('/bar/123').search('x=abc'); - scope.$digest(); - expect(scope.$service('$routeParams')).toBe(firstRouteParams); - }); + })); }); -- cgit v1.2.3