feat($timeout-mock): add verifyNoPendingTasks method

added verifyNoPendingTasks method, which throws error if not all
deferred tasks have been flushed

Closes #1245
This commit is contained in:
petrovalex
2012-09-15 19:02:10 +03:00
committed by Pawel Kozlowski
parent 59d9b89852
commit f0c6ebc076
2 changed files with 59 additions and 17 deletions

View File

@@ -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();
}));
});