diff options
| author | Igor Minar | 2012-06-12 00:35:28 -0700 |
|---|---|---|
| committer | Igor Minar | 2012-06-12 01:09:07 -0700 |
| commit | 9af7a9198e2d30608ea6c40eedde03e44a6ef569 (patch) | |
| tree | 24249e527de5b833d95cb733e461a20ef71d28d6 /test | |
| parent | 74fa65ecb7c4e2df966a179952b35700912e065f (diff) | |
| download | angular.js-9af7a9198e2d30608ea6c40eedde03e44a6ef569.tar.bz2 | |
fix($defer): remove deprecated $defer service
Diffstat (limited to 'test')
| -rw-r--r-- | test/ng/deferSpec.js | 114 | ||||
| -rw-r--r-- | test/ngMock/angular-mocksSpec.js | 2 |
2 files changed, 1 insertions, 115 deletions
diff --git a/test/ng/deferSpec.js b/test/ng/deferSpec.js deleted file mode 100644 index 2e31aadb..00000000 --- a/test/ng/deferSpec.js +++ /dev/null @@ -1,114 +0,0 @@ -'use strict'; - -describe('$defer', function() { - beforeEach(module(function($provide) { - $provide.factory('$exceptionHandler', function(){ - return jasmine.createSpy('$exceptionHandler'); - }); - $provide.value('$log', {warn: noop}); - })); - - - it('should delegate functions to $browser.defer', inject(function($defer, $browser, $exceptionHandler) { - var counter = 0; - $defer(function() { counter++; }); - - expect(counter).toBe(0); - - $browser.defer.flush(); - expect(counter).toBe(1); - - expect(function() {$browser.defer.flush();}).toThrow('No deferred tasks to be flushed'); - expect(counter).toBe(1); - - expect($exceptionHandler).not.toHaveBeenCalled(); - })); - - - it('should delegate exception to the $exceptionHandler service', inject(function($defer, $browser, $exceptionHandler) { - $defer(function() {throw "Test Error";}); - expect($exceptionHandler).not.toHaveBeenCalled(); - - $browser.defer.flush(); - expect($exceptionHandler).toHaveBeenCalledWith("Test Error"); - })); - - - it('should call $apply after each callback is executed', inject(function($defer, $browser, $rootScope) { - var applySpy = this.spyOn($rootScope, '$apply').andCallThrough(); - - $defer(function() {}); - expect(applySpy).not.toHaveBeenCalled(); - - $browser.defer.flush(); - expect(applySpy).toHaveBeenCalled(); - - applySpy.reset(); //reset the spy; - - $defer(function() {}); - $defer(function() {}); - $browser.defer.flush(); - expect(applySpy.callCount).toBe(2); - })); - - - it('should call $apply even if an exception is thrown in callback', inject(function($defer, $browser, $rootScope) { - var applySpy = this.spyOn($rootScope, '$apply').andCallThrough(); - - $defer(function() {throw "Test Error";}); - expect(applySpy).not.toHaveBeenCalled(); - - $browser.defer.flush(); - expect(applySpy).toHaveBeenCalled(); - })); - - - it('should allow you to specify the delay time', inject(function($defer, $browser) { - var defer = this.spyOn($browser, 'defer'); - $defer(noop, 123); - expect(defer.callCount).toEqual(1); - expect(defer.mostRecentCall.args[1]).toEqual(123); - })); - - - it('should return a cancelation token', inject(function($defer, $browser) { - var defer = this.spyOn($browser, 'defer').andReturn('xxx'); - expect($defer(noop)).toEqual('xxx'); - })); - - - describe('cancel', function() { - it('should cancel tasks', inject(function($defer, $browser) { - var task1 = jasmine.createSpy('task1'), - task2 = jasmine.createSpy('task2'), - task3 = jasmine.createSpy('task3'), - token1, token3; - - token1 = $defer(task1); - $defer(task2); - token3 = $defer(task3, 333); - - $defer.cancel(token3); - $defer.cancel(token1); - $browser.defer.flush(); - - expect(task1).not.toHaveBeenCalled(); - expect(task2).toHaveBeenCalledOnce(); - expect(task3).not.toHaveBeenCalled(); - })); - - - it('should return true if a task was succesffuly canceled', inject(function($defer, $browser) { - var task1 = jasmine.createSpy('task1'), - task2 = jasmine.createSpy('task2'), - token1, token2; - - token1 = $defer(task1); - $browser.defer.flush(); - token2 = $defer(task2); - - expect($defer.cancel(token1)).toBe(false); - expect($defer.cancel(token2)).toBe(true); - })); - }); -}); diff --git a/test/ngMock/angular-mocksSpec.js b/test/ngMock/angular-mocksSpec.js index f4f6a346..5992846d 100644 --- a/test/ngMock/angular-mocksSpec.js +++ b/test/ngMock/angular-mocksSpec.js @@ -989,7 +989,7 @@ describe('ngMockE2E', function() { describe('autoflush', function() { - it('should flush responses via $defer', inject(function($browser) { + it('should flush responses via $browser.defer', inject(function($browser) { hb.when('GET', '/foo').respond('bar'); hb('GET', '/foo', null, callback); |
