mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-31 13:30:29 +00:00
test(ng:view): spec cleanup
- remove optional controller definition from specs - remove extranious digest calls
This commit is contained in:
parent
163c799eff
commit
bb948176aa
1 changed files with 5 additions and 11 deletions
|
|
@ -429,56 +429,50 @@ describe("widget", function() {
|
|||
|
||||
|
||||
it('should load content via xhr when route changes', function() {
|
||||
$route.when('/foo', {controller: angular.noop, template: 'myUrl1'});
|
||||
$route.when('/bar', {controller: angular.noop, template: 'myUrl2'});
|
||||
$route.when('/foo', {template: 'myUrl1'});
|
||||
$route.when('/bar', {template: 'myUrl2'});
|
||||
|
||||
expect(rootScope.$element.text()).toEqual('');
|
||||
|
||||
$location.path('/foo');
|
||||
$browser.xhr.expectGET('myUrl1').respond('<div>{{1+3}}</div>');
|
||||
rootScope.$digest();
|
||||
rootScope.$digest();
|
||||
$browser.xhr.flush();
|
||||
expect(rootScope.$element.text()).toEqual('4');
|
||||
|
||||
$location.path('/bar');
|
||||
$browser.xhr.expectGET('myUrl2').respond('angular is da best');
|
||||
rootScope.$digest();
|
||||
rootScope.$digest();
|
||||
$browser.xhr.flush();
|
||||
expect(rootScope.$element.text()).toEqual('angular is da best');
|
||||
});
|
||||
|
||||
it('should remove all content when location changes to an unknown route', function() {
|
||||
$route.when('/foo', {controller: angular.noop, template: 'myUrl1'});
|
||||
$route.when('/foo', {template: 'myUrl1'});
|
||||
|
||||
$location.path('/foo');
|
||||
$browser.xhr.expectGET('myUrl1').respond('<div>{{1+3}}</div>');
|
||||
rootScope.$digest();
|
||||
rootScope.$digest();
|
||||
$browser.xhr.flush();
|
||||
expect(rootScope.$element.text()).toEqual('4');
|
||||
|
||||
$location.path('/unknown');
|
||||
rootScope.$digest();
|
||||
rootScope.$digest();
|
||||
expect(rootScope.$element.text()).toEqual('');
|
||||
});
|
||||
|
||||
it('should chain scopes and propagate evals to the child scope', function() {
|
||||
$route.when('/foo', {controller: angular.noop, template: 'myUrl1'});
|
||||
$route.when('/foo', {template: 'myUrl1'});
|
||||
rootScope.parentVar = 'parent';
|
||||
|
||||
$location.path('/foo');
|
||||
$browser.xhr.expectGET('myUrl1').respond('<div>{{parentVar}}</div>');
|
||||
rootScope.$digest();
|
||||
rootScope.$digest();
|
||||
$browser.xhr.flush();
|
||||
expect(rootScope.$element.text()).toEqual('parent');
|
||||
|
||||
rootScope.parentVar = 'new parent';
|
||||
rootScope.$digest();
|
||||
rootScope.$digest();
|
||||
expect(rootScope.$element.text()).toEqual('new parent');
|
||||
});
|
||||
|
||||
|
|
@ -510,7 +504,7 @@ describe("widget", function() {
|
|||
|
||||
it('should initialize view template after the view controller was initialized even when ' +
|
||||
'templates were cached', function() {
|
||||
//this is a test for a regression that was introduced by making the ng:view cache sync
|
||||
// this is a test for a regression that was introduced by making the ng:view cache sync
|
||||
|
||||
$route.when('/foo', {controller: ParentCtrl, template: 'viewPartial.html'});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue