aboutsummaryrefslogtreecommitdiffstats
path: root/test/ngMock/angular-mocksSpec.js
diff options
context:
space:
mode:
authorpetrovalex2012-09-15 19:02:10 +0300
committerPawel Kozlowski2012-12-20 20:39:40 +0100
commitf0c6ebc07653f6267acec898ccef5677884e3081 (patch)
treef238d7ef4c30fa3e294be8955108da6bc445b692 /test/ngMock/angular-mocksSpec.js
parent59d9b89852805ad08e8e3bc2f80625b9697dc768 (diff)
downloadangular.js-f0c6ebc07653f6267acec898ccef5677884e3081.tar.bz2
feat($timeout-mock): add verifyNoPendingTasks method
added verifyNoPendingTasks method, which throws error if not all deferred tasks have been flushed Closes #1245
Diffstat (limited to 'test/ngMock/angular-mocksSpec.js')
-rw-r--r--test/ngMock/angular-mocksSpec.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ngMock/angular-mocksSpec.js b/test/ngMock/angular-mocksSpec.js
index 5992846d..d95f3003 100644
--- a/test/ngMock/angular-mocksSpec.js
+++ b/test/ngMock/angular-mocksSpec.js
@@ -327,6 +327,22 @@ describe('ngMock', function() {
$timeout.flush();
expect(logger).toEqual(['t1', 't3', 't2']);
}));
+
+
+ it('should throw an exception when not flushed', inject(function($timeout){
+ $timeout(noop);
+
+ var expectedError = 'Deferred tasks to flush (1): {id: 0, time: 0}';
+ expect(function() {$timeout.verifyNoPendingTasks();}).toThrow(expectedError);
+ }));
+
+
+ it('should do nothing when all tasks have been flushed', inject(function($timeout) {
+ $timeout(noop);
+
+ $timeout.flush();
+ expect(function() {$timeout.verifyNoPendingTasks();}).not.toThrow();
+ }));
});