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

Commit 284de57

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

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/ng/intervalSpec.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,4 +267,25 @@ describe('$interval', function() {
267267
expect($interval.cancel()).toBe(false);
268268
}));
269269
});
270+
271+
describe('$window delegation', function() {
272+
it('should use $window.setInterval instead of the global function', inject(function ($interval, $window) {
273+
var setIntervalSpy = spyOn($window, 'setInterval');
274+
275+
$interval(noop, 1000);
276+
expect(setIntervalSpy).toHaveBeenCalled();
277+
}));
278+
279+
it('should use $window.clearInterval instead of the global function', inject(function ($interval, $window) {
280+
var clearIntervalSpy = spyOn($window, 'clearInterval');
281+
282+
$interval(noop, 1000, 1);
283+
$window.flush(1000);
284+
expect(clearIntervalSpy).toHaveBeenCalled();
285+
286+
clearIntervalSpy.reset();
287+
$interval.cancel($interval(noop, 1000));
288+
expect(clearIntervalSpy).toHaveBeenCalled();
289+
}));
290+
});
270291
});

0 commit comments

Comments
 (0)