adding spec for controller-less $route definitions

This commit is contained in:
Igor Minar 2011-01-30 15:49:01 -08:00
parent 21ad176246
commit 7db3b54c1f

View file

@ -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();
});
});