@@ -26,31 +26,34 @@ describe('angular-meteor.core', function() {
2626 } ) ;
2727
2828 it ( 'should call Tracker.autorun()' , function ( ) {
29- var stoppable = { stop : jasmine . createSpy ( 'stop' ) } ;
29+ var stop = jasmine . createSpy ( 'stop' ) ;
30+ var stoppable = { stop : stop } ;
3031 spyOn ( Tracker , 'autorun' ) . and . returnValue ( stoppable ) ;
3132
3233 scope . autorun ( function ( ) { } ) ;
3334 expect ( Tracker . autorun ) . toHaveBeenCalled ( ) ;
3435 } ) ;
3536
3637 it ( 'should autostop computation' , function ( ) {
37- var stoppable = { stop : jasmine . createSpy ( 'stop' ) } ;
38+ var stop = jasmine . createSpy ( 'stop' ) ;
39+ var stoppable = { stop : stop } ;
3840 spyOn ( Tracker , 'autorun' ) . and . returnValue ( stoppable ) ;
3941
4042 scope . autorun ( angular . noop ) ;
4143 scope . $destroy ( ) ;
4244
43- expect ( stoppable . stop ) . toHaveBeenCalled ( ) ;
45+ expect ( stop ) . toHaveBeenCalled ( ) ;
4446 } ) ;
4547
4648 it ( 'should stop computation manually' , function ( ) {
47- var stoppable = { stop : jasmine . createSpy ( 'stop' ) } ;
49+ var stop = jasmine . createSpy ( 'stop' ) ;
50+ var stoppable = { stop : stop } ;
4851 spyOn ( Tracker , 'autorun' ) . and . returnValue ( stoppable ) ;
4952
5053 var computation = scope . autorun ( angular . noop ) ;
5154 computation . stop ( ) ;
5255
53- expect ( stoppable . stop ) . toHaveBeenCalled ( ) ;
56+ expect ( stop ) . toHaveBeenCalled ( ) ;
5457 } ) ;
5558
5659 it ( 'should call autorun function using view model as context' , function ( ) {
@@ -66,6 +69,18 @@ describe('angular-meteor.core', function() {
6669 scope . autorun ( angular . noop ) ;
6770 expect ( scope . $digest ) . toHaveBeenCalled ( ) ;
6871 } ) ;
72+
73+ it ( 'should remove the destroy event listener once the computation has been stopped' , function ( ) {
74+ var stop = jasmine . createSpy ( 'stop' ) ;
75+ var stoppable = { stop : stop } ;
76+ spyOn ( Tracker , 'autorun' ) . and . returnValue ( stoppable ) ;
77+
78+ var computation = scope . autorun ( angular . noop ) ;
79+ computation . stop ( ) ;
80+ scope . $destroy ( ) ;
81+
82+ expect ( stop . calls . count ( ) ) . toEqual ( 1 ) ;
83+ } ) ;
6984 } ) ;
7085
7186 describe ( 'subscribe()' , function ( ) {
@@ -87,23 +102,25 @@ describe('angular-meteor.core', function() {
87102 } ) ;
88103
89104 it ( 'should autostop subscription' , function ( ) {
90- var stoppable = { stop : jasmine . createSpy ( 'stop' ) } ;
105+ var stop = jasmine . createSpy ( 'stop' ) ;
106+ var stoppable = { stop : stop } ;
91107 spyOn ( Tracker , 'autorun' ) . and . returnValue ( stoppable ) ;
92108
93109 scope . subscribe ( 'test' ) ;
94110 scope . $destroy ( ) ;
95111
96- expect ( stoppable . stop ) . toHaveBeenCalled ( ) ;
112+ expect ( stop ) . toHaveBeenCalled ( ) ;
97113 } ) ;
98114
99115 it ( 'should stop subscription manually' , function ( ) {
100- var stoppable = { stop : jasmine . createSpy ( 'stop' ) } ;
116+ var stop = jasmine . createSpy ( 'stop' ) ;
117+ var stoppable = { stop : stop } ;
101118 spyOn ( Tracker , 'autorun' ) . and . returnValue ( stoppable ) ;
102119
103120 var subscription = scope . subscribe ( 'test' ) ;
104121 subscription . stop ( ) ;
105122
106- expect ( stoppable . stop ) . toHaveBeenCalled ( ) ;
123+ expect ( stop ) . toHaveBeenCalled ( ) ;
107124 } ) ;
108125
109126 it ( 'should return subscription ready and subscriptionId properties' , function ( done ) {
0 commit comments