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

Commit

Permalink
fix(ngMock): return false from mock $interval.cancel() when no argume…
Browse files Browse the repository at this point in the history
…nt is supplied

Closes #6103.
Closed #6099.
  • Loading branch information
dluxemburg authored and tbosch committed Feb 5, 2014
1 parent 36d37c0 commit dd24c78
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
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

0 comments on commit dd24c78

Please sign in to comment.