diff options
| author | Vojta Jina | 2012-03-30 15:03:20 -0700 |
|---|---|---|
| committer | Vojta Jina | 2012-04-03 10:10:44 -0700 |
| commit | 15c1fe392942b70e456f10afbdfd9c3329249a43 (patch) | |
| tree | bec93d124ab8bc1cbd283e250be5b037bcc1fce7 /test/ng/directive/ngViewSpec.js | |
| parent | 428f2b563663315df4f235ca19cef4bdcf82e2ab (diff) | |
| download | angular.js-15c1fe392942b70e456f10afbdfd9c3329249a43.tar.bz2 | |
refactor(ngView): remove extra $watch, refactor one ugly test
Diffstat (limited to 'test/ng/directive/ngViewSpec.js')
| -rw-r--r-- | test/ng/directive/ngViewSpec.js | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/test/ng/directive/ngViewSpec.js b/test/ng/directive/ngViewSpec.js index 636e15a8..4c0b841b 100644 --- a/test/ng/directive/ngViewSpec.js +++ b/test/ng/directive/ngViewSpec.js @@ -137,33 +137,29 @@ describe('ng-view', function() { }); - it('should be possible to nest ng-view in ng-include', inject(function() { - // TODO(vojta): refactor this test - dealoc(element); - var injector = angular.injector(['ng', 'ngMock', function($routeProvider) { - $routeProvider.when('/foo', {controller: angular.noop, template: 'viewPartial.html'}); - }]); - var myApp = injector.get('$rootScope'); - var $httpBackend = injector.get('$httpBackend'); - $httpBackend.expect('GET', 'includePartial.html').respond('view: <ng:view></ng:view>'); - injector.get('$location').path('/foo'); + it('should be possible to nest ng-view in ng-include', function() { + + module(function($routeProvider) { + $routeProvider.when('/foo', {template: 'viewPartial.html'}); + }); - var $route = injector.get('$route'); + inject(function($httpBackend, $location, $route, $compile, $rootScope) { + $httpBackend.whenGET('includePartial.html').respond('view: <ng:view></ng:view>'); + $httpBackend.whenGET('viewPartial.html').respond('content'); + $location.path('/foo'); - element = injector.get('$compile')( + var elm = $compile( '<div>' + 'include: <ng:include src="\'includePartial.html\'"> </ng:include>' + - '</div>')(myApp); - myApp.$apply(); - - $httpBackend.expect('GET', 'viewPartial.html').respond('content'); - $httpBackend.flush(); + '</div>')($rootScope); + $rootScope.$digest(); + $httpBackend.flush(); - expect(element.text()).toEqual('include: view: content'); - expect($route.current.template).toEqual('viewPartial.html'); - dealoc(myApp); - dealoc(element); - })); + expect(elm.text()).toEqual('include: view: content'); + expect($route.current.template).toEqual('viewPartial.html'); + dealoc(elm) + }); + }); it('should initialize view template after the view controller was initialized even when ' + |
