@@ -30,14 +30,18 @@ define(['./TimeConductorController'], function (TimeConductorController) {
30
30
var controller ;
31
31
32
32
beforeEach ( function ( ) {
33
- mockScope = jasmine . createSpyObj ( "$scope" , [ "$watch" ] ) ;
33
+ mockScope = jasmine . createSpyObj ( "$scope" , [
34
+ "$watch" ,
35
+ "$on"
36
+ ] ) ;
34
37
mockWindow = jasmine . createSpyObj ( "$window" , [ "requestAnimationFrame" ] ) ;
35
38
mockTimeConductor = jasmine . createSpyObj (
36
39
"TimeConductor" ,
37
40
[
38
41
"bounds" ,
39
42
"timeSystem" ,
40
- "on"
43
+ "on" ,
44
+ "off"
41
45
]
42
46
) ;
43
47
mockTimeConductor . bounds . andReturn ( { start : undefined , end : undefined } ) ;
@@ -124,9 +128,16 @@ define(['./TimeConductorController'], function (TimeConductorController) {
124
128
} ) ;
125
129
126
130
it ( "listens for changes to conductor state" , function ( ) {
127
- expect ( mockTimeConductor . on ) . toHaveBeenCalledWith ( "timeSystem" , jasmine . any ( Function ) ) ;
128
- expect ( mockTimeConductor . on ) . toHaveBeenCalledWith ( "bounds" , jasmine . any ( Function ) ) ;
129
- expect ( mockTimeConductor . on ) . toHaveBeenCalledWith ( "follow" , jasmine . any ( Function ) ) ;
131
+ expect ( mockTimeConductor . on ) . toHaveBeenCalledWith ( "timeSystem" , controller . changeTimeSystem ) ;
132
+ expect ( mockTimeConductor . on ) . toHaveBeenCalledWith ( "bounds" , controller . setFormFromBounds ) ;
133
+ } ) ;
134
+
135
+ it ( "deregisters conductor listens when scope is destroyed" , function ( ) {
136
+ expect ( mockScope . $on ) . toHaveBeenCalledWith ( "$destroy" , controller . destroy ) ;
137
+
138
+ controller . destroy ( ) ;
139
+ expect ( mockTimeConductor . off ) . toHaveBeenCalledWith ( "timeSystem" , controller . changeTimeSystem ) ;
140
+ expect ( mockTimeConductor . off ) . toHaveBeenCalledWith ( "bounds" , controller . setFormFromBounds ) ;
130
141
} ) ;
131
142
132
143
it ( "when time system changes, sets time system on scope" , function ( ) {
@@ -164,17 +175,6 @@ define(['./TimeConductorController'], function (TimeConductorController) {
164
175
expect ( mockScope . boundsModel . start ) . toEqual ( bounds . start ) ;
165
176
expect ( mockScope . boundsModel . end ) . toEqual ( bounds . end ) ;
166
177
} ) ;
167
-
168
- it ( "responds to a change in 'follow' state of the time conductor" , function ( ) {
169
- var followListener = getListener ( "follow" ) ;
170
- expect ( followListener ) . toBeDefined ( ) ;
171
-
172
- followListener ( true ) ;
173
- expect ( mockScope . followMode ) . toEqual ( true ) ;
174
-
175
- followListener ( false ) ;
176
- expect ( mockScope . followMode ) . toEqual ( false ) ;
177
- } ) ;
178
178
} ) ;
179
179
180
180
describe ( "when user makes changes from UI" , function ( ) {
0 commit comments