diff options
| author | Igor Minar | 2012-03-16 09:41:00 -0700 |
|---|---|---|
| committer | Igor Minar | 2012-03-16 09:41:05 -0700 |
| commit | 9b1aff905b638aa274a5fc8f88662df446d374bd (patch) | |
| tree | 481bc31495091a99fd187ef8e23b14e8441d7b28 /test/service | |
| parent | 252d4548f981e18f496877f0f1a30a6c05c8600f (diff) | |
| download | angular.js-9b1aff905b638aa274a5fc8f88662df446d374bd.tar.bz2 | |
feat(scope): broadcast $destroy event on scope destruction
perf testing shows that in chrome this change adds 5-15% overhead
when destroying 10k nested scopes where each scope has a $destroy listener
Diffstat (limited to 'test/service')
| -rw-r--r-- | test/service/scopeSpec.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/service/scopeSpec.js b/test/service/scopeSpec.js index 95b028fe..972584cf 100644 --- a/test/service/scopeSpec.js +++ b/test/service/scopeSpec.js @@ -2,6 +2,9 @@ describe('Scope', function() { + beforeEach(module(provideLog)); + + describe('$root', function() { it('should point to itself', inject(function($rootScope) { expect($rootScope.$root).toEqual($rootScope); @@ -393,6 +396,15 @@ describe('Scope', function() { $rootScope.$digest(); expect(log).toEqual('12'); })); + + + it('should broadcast the $destroy event', inject(function($rootScope, log) { + first.$on('$destroy', log.fn('first')); + first.$new().$on('$destroy', log.fn('first-child')); + + first.$destroy(); + expect(log).toEqual('first; first-child'); + })); }); |
