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

Commit bc59550

Browse files
committed
test($interval): add tests making sure $interval uses the methods from $window
1 parent a4904c0 commit bc59550

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/ng/intervalSpec.js

+21
Original file line numberDiff line numberDiff line change
@@ -286,4 +286,25 @@ describe('$interval', function() {
286286
expect($interval.cancel()).toBe(false);
287287
}));
288288
});
289+
290+
describe('$window delegation', function() {
291+
it('should use $window.setInterval instead of the global function', inject(function ($interval, $window) {
292+
var setIntervalSpy = spyOn($window, 'setInterval');
293+
294+
$interval(noop, 1000);
295+
expect(setIntervalSpy).toHaveBeenCalled();
296+
}));
297+
298+
it('should use $window.clearInterval instead of the global function', inject(function ($interval, $window) {
299+
var clearIntervalSpy = spyOn($window, 'clearInterval');
300+
301+
$interval(noop, 1000, 1);
302+
$window.flush(1000);
303+
expect(clearIntervalSpy).toHaveBeenCalled();
304+
305+
clearIntervalSpy.reset();
306+
$interval.cancel($interval(noop, 1000));
307+
expect(clearIntervalSpy).toHaveBeenCalled();
308+
}));
309+
});
289310
});

0 commit comments

Comments
 (0)