diff options
| author | Misko Hevery | 2011-08-11 15:19:26 -0700 |
|---|---|---|
| committer | Misko Hevery | 2011-08-12 16:18:41 -0700 |
| commit | 3f99cdbdc30e85c2100acd7cbe67052befd08776 (patch) | |
| tree | dd16babb99b2874cdde91cecde85e1d1ed6e7ccd /test | |
| parent | 13e7df68a65b0dd2eb4eed673f7b8e3e702d72a9 (diff) | |
| download | angular.js-3f99cdbdc30e85c2100acd7cbe67052befd08776.tar.bz2 | |
feat(scope): $evalAsync support
Diffstat (limited to 'test')
| -rw-r--r-- | test/ScopeSpec.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/ScopeSpec.js b/test/ScopeSpec.js index 5a14abd6..b3edad6c 100644 --- a/test/ScopeSpec.js +++ b/test/ScopeSpec.js @@ -306,6 +306,41 @@ describe('Scope', function(){ }); }); + describe('$evalAsync', function(){ + + it('should run callback before $watch', function(){ + var log = ''; + var child = root.$new(); + root.$evalAsync(function(scope){ log += 'parent.async;'; }); + root.$watch('value', function(){ log += 'parent.$digest;'; }); + child.$evalAsync(function(scope){ log += 'child.async;'; }); + child.$watch('value', function(){ log += 'child.$digest;'; }); + root.$digest(); + expect(log).toEqual('parent.async;parent.$digest;child.async;child.$digest;'); + }); + + it('should cause a $digest rerun', function(){ + root.log = ''; + root.value = 0; + root.$watch('value', 'log = log + ".";'); + root.$watch('init', function(){ + root.$evalAsync('value = 123; log = log + "=" '); + expect(root.value).toEqual(0); + }); + root.$digest(); + expect(root.log).toEqual('.=.'); + }); + + it('should run async in the same order as added', function(){ + root.log = ''; + root.$evalAsync("log = log + 1"); + root.$evalAsync("log = log + 2"); + root.$digest(); + expect(root.log).toBe('12'); + }); + + }); + describe('$apply', function(){ it('should apply expression with full lifecycle', function(){ |
