diff options
| author | Matias Niemelä | 2014-02-24 18:14:29 -0500 |
|---|---|---|
| committer | Matias Niemelä | 2014-02-24 21:23:05 -0500 |
| commit | 04d7317cdd95ba00783389f89f6e9a7e1fc418f8 (patch) | |
| tree | c0eff0f1d143a3340c40b532a3ffd4149787d0a0 /test/ng/rafSpec.js | |
| parent | 2cd87dbb93497e38ffad016c1f5766c2bb56e604 (diff) | |
| download | angular.js-04d7317cdd95ba00783389f89f6e9a7e1fc418f8.tar.bz2 | |
chore(core): introduce a wrapper for requestAnimationFrame
Diffstat (limited to 'test/ng/rafSpec.js')
| -rw-r--r-- | test/ng/rafSpec.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test/ng/rafSpec.js b/test/ng/rafSpec.js new file mode 100644 index 00000000..6c15e2d2 --- /dev/null +++ b/test/ng/rafSpec.js @@ -0,0 +1,47 @@ +'use strict'; + +describe('$$rAF', function() { + it('should queue and block animation frames', inject(function($$rAF) { + if(!$$rAF.supported) return; + + var message; + $$rAF(function() { + message = 'yes'; + }); + + expect(message).toBeUndefined(); + $$rAF.flush(); + expect(message).toBe('yes'); + })); + + it('should provide a cancellation method', inject(function($$rAF) { + if(!$$rAF.supported) return; + + var present = true; + var cancel = $$rAF(function() { + present = false; + }); + + expect(present).toBe(true); + cancel(); + + try { + $$rAF.flush(); + } catch(e) {}; + expect(present).toBe(true); + })); + + describe('mocks', function() { + it('should throw an error if no frames are present', inject(function($$rAF) { + if($$rAF.supported) { + var failed = false; + try { + $$rAF.flush(); + } catch(e) { + failed = true; + } + expect(failed).toBe(true); + } + })); + }); +}); |
