From f63a125e9d0a5ae68de91974d99ae57a1261175c Mon Sep 17 00:00:00 2001 From: Chris Chua Date: Mon, 23 Dec 2013 03:44:29 -0800 Subject: [PATCH] test(carousel): check timers on scope destruction Reproduce #1414 --- src/carousel/test/carousel.spec.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/carousel/test/carousel.spec.js b/src/carousel/test/carousel.spec.js index 0bea1d3daa..78d41699c3 100644 --- a/src/carousel/test/carousel.spec.js +++ b/src/carousel/test/carousel.spec.js @@ -294,6 +294,20 @@ describe('carousel', function() { expect(ctrl.slides.length).toBe(1); expect(ctrl.currentSlide).toBe(ctrl.slides[0]); }); + + it('issue 1414 - should not continue running timers after scope is destroyed', function() { + spyOn(scope, 'next').andCallThrough(); + scope.interval = 2000; + scope.$digest(); + + $timeout.flush(); + expect(scope.next.calls.length).toBe(1); + + scope.$destroy(); + + $timeout.flush(scope.interval); + expect(scope.next.calls.length).toBe(1); + }); }); }); });