diff options
| author | Matias Niemelä | 2013-07-24 23:22:09 -0400 | 
|---|---|---|
| committer | Igor Minar | 2013-07-26 08:57:25 -0700 | 
| commit | 462ed033d512ae94cb188efc9453de84ace4e17e (patch) | |
| tree | 0ddf743c25207230ec15e79eeb89ad492e925dec /test/ngMock/angular-mocksSpec.js | |
| parent | b7fdabc4bf2a9dd11a57f98c5229d834c4589bab (diff) | |
| download | angular.js-462ed033d512ae94cb188efc9453de84ace4e17e.tar.bz2 | |
feat(ngMock): $timeout.flushNext can expect specific timeout delays
the $timeout mock's flush method allows flushing queued up requests
but doesn't allow to for checking with what delay a task was queued
up. flushNext flushes the next queued up task and can asserts the
scheduled delay.
Diffstat (limited to 'test/ngMock/angular-mocksSpec.js')
| -rw-r--r-- | test/ngMock/angular-mocksSpec.js | 15 | 
1 files changed, 15 insertions, 0 deletions
| diff --git a/test/ngMock/angular-mocksSpec.js b/test/ngMock/angular-mocksSpec.js index 37bf001a..4d238891 100644 --- a/test/ngMock/angular-mocksSpec.js +++ b/test/ngMock/angular-mocksSpec.js @@ -365,6 +365,21 @@ describe('ngMock', function() {        $timeout.flush(900);        expect(function() {$timeout.verifyNoPendingTasks();}).not.toThrow();      })); + + +    it('should assert against the delay value', inject(function($timeout) { +      var count = 0; +      var iterate = function() { +        count++; +      }; + +      $timeout(iterate, 100); +      $timeout(iterate, 123); +      $timeout.flushNext(100); +      expect(count).toBe(1); +      $timeout.flushNext(123); +      expect(count).toBe(2); +    }));    }); | 
