diff options
| author | Matias Niemelä | 2014-03-14 12:01:45 -0400 |
|---|---|---|
| committer | Matias Niemelä | 2014-03-14 12:42:07 -0400 |
| commit | 7b5e019981f352add88be2984de68e553d1bfa93 (patch) | |
| tree | ffa2a2c0154031f6d2c53ab4f77b0f63f0cc50d8 /test/ng | |
| parent | 129e2e021ab1d773874428cd1fb329eae72797c4 (diff) | |
| download | angular.js-7b5e019981f352add88be2984de68e553d1bfa93.tar.bz2 | |
fix($$rAF): always fallback to a $timeout incase native rAF isn't supported
Closes #6654
Diffstat (limited to 'test/ng')
| -rw-r--r-- | test/ng/rafSpec.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/ng/rafSpec.js b/test/ng/rafSpec.js index 6c15e2d2..8bf76efd 100644 --- a/test/ng/rafSpec.js +++ b/test/ng/rafSpec.js @@ -31,6 +31,38 @@ describe('$$rAF', function() { expect(present).toBe(true); })); + describe('$timeout fallback', function() { + it("it should use a $timeout incase native rAF isn't suppored", function() { + var timeoutSpy = jasmine.createSpy('callback'); + + //we need to create our own injector to work around the ngMock overrides + var injector = createInjector(['ng', function($provide) { + $provide.value('$timeout', timeoutSpy); + $provide.decorator('$window', function($delegate) { + $delegate.requestAnimationFrame = false; + $delegate.webkitRequestAnimationFrame = false; + $delegate.mozRequestAnimationFrame = false; + return $delegate; + }); + }]); + + var $$rAF = injector.get('$$rAF'); + expect($$rAF.supported).toBe(false); + + var message; + $$rAF(function() { + message = 'on'; + }); + + expect(message).toBeUndefined(); + expect(timeoutSpy).toHaveBeenCalled(); + + timeoutSpy.mostRecentCall.args[0](); + + expect(message).toBe('on'); + }); + }); + describe('mocks', function() { it('should throw an error if no frames are present', inject(function($$rAF) { if($$rAF.supported) { |
