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

fix(ngMock): return immediately from mock $interval.cancel() when no promise argument is supplied #6103

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ngMock/angular-mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ angular.mock.$IntervalProvider = function() {
};

$interval.cancel = function(promise) {
if(!promise) return false;
var fnIndex;

angular.forEach(repeatFns, function(fn, index) {
Expand Down
5 changes: 5 additions & 0 deletions test/ngMock/angular-mocksSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}));
});
Expand Down