aboutsummaryrefslogtreecommitdiffstats
path: root/test/widgetsSpec.js
diff options
context:
space:
mode:
authorVojta Jina2012-02-19 12:59:10 -0800
committerVojta Jina2012-02-28 17:48:07 -0800
commit60743fc52aea9eabee58258a31f4ba465013cb4e (patch)
treef148f23deab430bb33f84925af9f2afee17ac075 /test/widgetsSpec.js
parent9486590e1be7282bb0e87586a35ca0bee6c64ee0 (diff)
downloadangular.js-60743fc52aea9eabee58258a31f4ba465013cb4e.tar.bz2
feat(ng:include) Fire $contentLoaded event
+ refactor unload to listen on this event -> we can use unload with ng:view as well Closes #743
Diffstat (limited to 'test/widgetsSpec.js')
-rw-r--r--test/widgetsSpec.js36
1 files changed, 34 insertions, 2 deletions
diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js
index d9517866..f75d81c2 100644
--- a/test/widgetsSpec.js
+++ b/test/widgetsSpec.js
@@ -119,6 +119,22 @@ describe('widget', function() {
}));
+ it('should fire $contentLoaded event after linking the content', inject(
+ function($rootScope, $compile, $templateCache) {
+ var contentLoadedSpy = jasmine.createSpy('content loaded').andCallFake(function() {
+ expect(element.text()).toBe('partial content');
+ });
+
+ $templateCache.put('url', [200, 'partial content', {}]);
+ $rootScope.$on('$contentLoaded', contentLoadedSpy);
+
+ element = $compile('<ng:include src="\'url\'"></ng:include>')($rootScope);
+ $rootScope.$digest();
+
+ expect(contentLoadedSpy).toHaveBeenCalledOnce();
+ }));
+
+
it('should evaluate onload expression when a partial is loaded', inject(
putIntoCache('myUrl', 'my partial'),
function($rootScope, $compile, $browser) {
@@ -620,7 +636,7 @@ describe('widget', function() {
describe('ng:view', function() {
beforeEach(module(function() {
return function($rootScope, $compile) {
- element = $compile('<ng:view></ng:view>')($rootScope);
+ element = $compile('<ng:view onload="load()"></ng:view>')($rootScope);
};
}));
@@ -847,7 +863,7 @@ describe('widget', function() {
$routeProvider.when('/foo', {controller: noop, template: 'myUrl1'});
});
- inject(function($route, $rootScope, $location, $templateCache, $browser) {
+ inject(function($route, $rootScope, $location, $templateCache) {
$templateCache.put('myUrl1', [200, 'my partial', {}]);
$location.path('/foo');
@@ -1004,6 +1020,22 @@ describe('widget', function() {
expect(log).toEqual(['init-foo', 'route-update', 'destroy-foo', 'init-bar']);
});
});
+
+
+ it('should evaluate onload expression after linking the content', function() {
+ module(function($routeProvider) {
+ $routeProvider.when('/foo', {template: 'tpl.html'});
+ });
+
+ inject(function($templateCache, $location, $rootScope) {
+ $templateCache.put('tpl.html', [200, '{{1+1}}', {}]);
+ $rootScope.load = jasmine.createSpy('onload');
+
+ $location.url('/foo');
+ $rootScope.$digest();
+ expect($rootScope.load).toHaveBeenCalledOnce();
+ });
+ })
});