Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit dd24c78

Browse files
dluxemburgtbosch
authored andcommitted
fix(ngMock): return false from mock $interval.cancel() when no argument is supplied
Closes #6103. Closed #6099.
1 parent 36d37c0 commit dd24c78

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/ngMock/angular-mocks.js

+1
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ angular.mock.$IntervalProvider = function() {
504504
};
505505

506506
$interval.cancel = function(promise) {
507+
if(!promise) return false;
507508
var fnIndex;
508509

509510
angular.forEach(repeatFns, function(fn, index) {

test/ngMock/angular-mocksSpec.js

+5
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,11 @@ describe('ngMock', function() {
509509

510510
it('should not throw a runtime exception when given an undefined promise',
511511
inject(function($interval) {
512+
var task1 = jasmine.createSpy('task1'),
513+
promise1;
514+
515+
promise1 = $interval(task1, 1000, 1);
516+
512517
expect($interval.cancel()).toBe(false);
513518
}));
514519
});

0 commit comments

Comments
 (0)