mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-23 03:30:02 +08:00
test($interval): add tests making sure $interval uses the methods from $window
This commit is contained in:
@@ -286,4 +286,25 @@ describe('$interval', function() {
|
||||
expect($interval.cancel()).toBe(false);
|
||||
}));
|
||||
});
|
||||
|
||||
describe('$window delegation', function() {
|
||||
it('should use $window.setInterval instead of the global function', inject(function ($interval, $window) {
|
||||
var setIntervalSpy = spyOn($window, 'setInterval');
|
||||
|
||||
$interval(noop, 1000);
|
||||
expect(setIntervalSpy).toHaveBeenCalled();
|
||||
}));
|
||||
|
||||
it('should use $window.clearInterval instead of the global function', inject(function ($interval, $window) {
|
||||
var clearIntervalSpy = spyOn($window, 'clearInterval');
|
||||
|
||||
$interval(noop, 1000, 1);
|
||||
$window.flush(1000);
|
||||
expect(clearIntervalSpy).toHaveBeenCalled();
|
||||
|
||||
clearIntervalSpy.reset();
|
||||
$interval.cancel($interval(noop, 1000));
|
||||
expect(clearIntervalSpy).toHaveBeenCalled();
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user