diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js index bb720c1d9e14..a6bcea88be64 100644 --- a/src/ngMock/angular-mocks.js +++ b/src/ngMock/angular-mocks.js @@ -504,6 +504,7 @@ angular.mock.$IntervalProvider = function() { }; $interval.cancel = function(promise) { + if(!promise) return false; var fnIndex; angular.forEach(repeatFns, function(fn, index) { diff --git a/test/ngMock/angular-mocksSpec.js b/test/ngMock/angular-mocksSpec.js index e5f67a7ebc48..c2b6108dfb33 100644 --- a/test/ngMock/angular-mocksSpec.js +++ b/test/ngMock/angular-mocksSpec.js @@ -509,6 +509,11 @@ describe('ngMock', function() { it('should not throw a runtime exception when given an undefined promise', inject(function($interval) { + var task1 = jasmine.createSpy('task1'), + promise1; + + promise1 = $interval(task1, 1000, 1); + expect($interval.cancel()).toBe(false); })); });