diff options
| -rw-r--r-- | src/ngMock/angular-mocks.js | 6 | ||||
| -rw-r--r-- | test/ngMock/angular-mocksSpec.js | 14 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js index 3024a4c9..aed67c29 100644 --- a/src/ngMock/angular-mocks.js +++ b/src/ngMock/angular-mocks.js @@ -1487,9 +1487,11 @@ angular.mock.$TimeoutDecorator = function($delegate, $browser) { * @description * * Flushes the queue of pending tasks. + * + * @param {number=} delay maximum timeout amount to flush up until */ - $delegate.flush = function() { - $browser.defer.flush(); + $delegate.flush = function(delay) { + $browser.defer.flush(delay); }; /** diff --git a/test/ngMock/angular-mocksSpec.js b/test/ngMock/angular-mocksSpec.js index 4e17dfb2..37bf001a 100644 --- a/test/ngMock/angular-mocksSpec.js +++ b/test/ngMock/angular-mocksSpec.js @@ -351,6 +351,20 @@ describe('ngMock', function() { $timeout.flush(); expect(function() {$timeout.verifyNoPendingTasks();}).not.toThrow(); })); + + + it('should check against the delay if provided within timeout', inject(function($timeout) { + $timeout(noop, 100); + $timeout.flush(100); + expect(function() {$timeout.verifyNoPendingTasks();}).not.toThrow(); + + $timeout(noop, 1000); + $timeout.flush(100); + expect(function() {$timeout.verifyNoPendingTasks();}).toThrow(); + + $timeout.flush(900); + expect(function() {$timeout.verifyNoPendingTasks();}).not.toThrow(); + })); }); |
