From 7db3b54c1f777327a1213d7f7b761d238cdf9652 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Sun, 30 Jan 2011 15:49:01 -0800 Subject: adding spec for controller-less $route definitions --- test/servicesSpec.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/servicesSpec.js') diff --git a/test/servicesSpec.js b/test/servicesSpec.js index c3c10552..c4fadec8 100644 --- a/test/servicesSpec.js +++ b/test/servicesSpec.js @@ -392,6 +392,25 @@ describe("service", function(){ scope.$eval(); expect($route.current.template).toEqual('instant update'); }); + + it('should allow routes to be defined with just templates without controllers', function() { + var scope = angular.scope(), + $location = scope.$service('$location'), + $route = scope.$service('$route'), + onChangeSpy = jasmine.createSpy('onChange'); + + $route.when('/foo', {template: 'foo.html'}); + $route.onChange(onChangeSpy); + expect($route.current).toBeNull(); + expect(onChangeSpy).not.toHaveBeenCalled(); + + $location.updateHash('/foo'); + scope.$eval(); + + expect($route.current.template).toEqual('foo.html'); + expect($route.current.controller).toBeUndefined(); + expect(onChangeSpy).toHaveBeenCalled(); + }); }); -- cgit v1.2.3