@@ -119,6 +119,22 @@ describe('widget', function() {
119119 } ) ) ;
120120
121121
122+ it ( 'should fire $contentLoaded event after linking the content' , inject (
123+ function ( $rootScope , $compile , $templateCache ) {
124+ var contentLoadedSpy = jasmine . createSpy ( 'content loaded' ) . andCallFake ( function ( ) {
125+ expect ( element . text ( ) ) . toBe ( 'partial content' ) ;
126+ } ) ;
127+
128+ $templateCache . put ( 'url' , [ 200 , 'partial content' , { } ] ) ;
129+ $rootScope . $on ( '$contentLoaded' , contentLoadedSpy ) ;
130+
131+ element = $compile ( '<ng:include src="\'url\'"></ng:include>' ) ( $rootScope ) ;
132+ $rootScope . $digest ( ) ;
133+
134+ expect ( contentLoadedSpy ) . toHaveBeenCalledOnce ( ) ;
135+ } ) ) ;
136+
137+
122138 it ( 'should evaluate onload expression when a partial is loaded' , inject (
123139 putIntoCache ( 'myUrl' , 'my partial' ) ,
124140 function ( $rootScope , $compile , $browser ) {
@@ -620,7 +636,7 @@ describe('widget', function() {
620636 describe ( 'ng:view' , function ( ) {
621637 beforeEach ( module ( function ( ) {
622638 return function ( $rootScope , $compile ) {
623- element = $compile ( '<ng:view></ng:view>' ) ( $rootScope ) ;
639+ element = $compile ( '<ng:view onload="load()" ></ng:view>' ) ( $rootScope ) ;
624640 } ;
625641 } ) ) ;
626642
@@ -847,7 +863,7 @@ describe('widget', function() {
847863 $routeProvider . when ( '/foo' , { controller : noop , template : 'myUrl1' } ) ;
848864 } ) ;
849865
850- inject ( function ( $route , $rootScope , $location , $templateCache , $browser ) {
866+ inject ( function ( $route , $rootScope , $location , $templateCache ) {
851867 $templateCache . put ( 'myUrl1' , [ 200 , 'my partial' , { } ] ) ;
852868 $location . path ( '/foo' ) ;
853869
@@ -1004,6 +1020,22 @@ describe('widget', function() {
10041020 expect ( log ) . toEqual ( [ 'init-foo' , 'route-update' , 'destroy-foo' , 'init-bar' ] ) ;
10051021 } ) ;
10061022 } ) ;
1023+
1024+
1025+ it ( 'should evaluate onload expression after linking the content' , function ( ) {
1026+ module ( function ( $routeProvider ) {
1027+ $routeProvider . when ( '/foo' , { template : 'tpl.html' } ) ;
1028+ } ) ;
1029+
1030+ inject ( function ( $templateCache , $location , $rootScope ) {
1031+ $templateCache . put ( 'tpl.html' , [ 200 , '{{1+1}}' , { } ] ) ;
1032+ $rootScope . load = jasmine . createSpy ( 'onload' ) ;
1033+
1034+ $location . url ( '/foo' ) ;
1035+ $rootScope . $digest ( ) ;
1036+ expect ( $rootScope . load ) . toHaveBeenCalledOnce ( ) ;
1037+ } ) ;
1038+ } )
10071039 } ) ;
10081040
10091041
0 commit comments