@@ -100,19 +100,14 @@ describe("j5Redux class", () => {
100
100
}
101
101
} ,
102
102
listenersSubscribe : {
103
- status : function ( status , j5 ) {
103
+ status : function ( state , j5 ) {
104
104
var data = {
105
105
on : false ,
106
106
blink : false
107
107
} ;
108
- if ( status === 'monkey' ) {
108
+ if ( state . status === 'monkey' ) {
109
109
callback ( ) ;
110
110
}
111
- if ( status === 'testInteraction' ) {
112
- data . color = j5 . id ;
113
- data . on = true ;
114
- store . dispatch ( setJ5Components ( 'rgb' , data , 'game_light' ) ) ;
115
- }
116
111
}
117
112
}
118
113
} ) ;
@@ -132,13 +127,17 @@ describe("j5Redux class", () => {
132
127
} ) ;
133
128
134
129
it ( "buttons.getj5Objects() will return 2 j5 buttons " , function ( ) {
135
- var j5Objects = buttons . getj5Objects ( ) ;
136
- expect ( j5Objects . length ) . to . equal ( 2 ) ;
130
+ var j5Objects = buttons . getJ5Objects ( ) ;
131
+ expect ( j5Objects ) . to . have . property ( "white" ) ;
132
+ expect ( j5Objects ) . to . have . property ( "black" ) ;
133
+ var allKeys = Object . keys ( j5Objects ) ;
134
+ expect ( allKeys . length ) . to . equal ( 2 ) ;
137
135
} ) ;
138
136
139
137
it ( "buttons.getState() returns the button state in redux " , function ( ) {
140
138
var getState = buttons . getState ( ) ;
141
139
var reduxState = store . getState ( ) . J5 . game_buttons ;
140
+
142
141
expect ( getState ) . to . be . eql ( reduxState ) ;
143
142
} ) ;
144
143
@@ -165,8 +164,8 @@ describe("j5Redux class", () => {
165
164
expect ( spies . setUpEvents . callCount ) . to . equal ( 2 ) ;
166
165
} ) ;
167
166
168
- it ( "setUpListeners to be called twice for each????? BUG??? " , function ( ) {
169
- expect ( spies . setUpListeners . callCount ) . to . equal ( 2 ) ;
167
+ it ( "setUpListeners to be called once " , function ( ) {
168
+ expect ( spies . setUpListeners . callCount ) . to . equal ( 1 ) ;
170
169
} ) ;
171
170
172
171
it ( "if the dispatcher changes the state in redux, then the listener will fire" , function ( ) {
@@ -178,18 +177,10 @@ describe("j5Redux class", () => {
178
177
179
178
it ( "buttons.resetReduxState() will reset the state of each button in redux to original state" , function ( ) {
180
179
store . dispatch ( setJ5Components ( 'white' , { status : 'monkey' } , 'game_buttons' ) ) ;
180
+
181
181
buttons . resetReduxState ( ) ;
182
182
var state = store . getState ( ) . J5 . game_buttons . white ;
183
183
expect ( state . status ) . to . equal ( null ) ;
184
184
} ) ;
185
185
186
- it ( "button listener will dispatch to light state, light listener will fire" , function ( ) {
187
- store . dispatch ( setJ5Components ( 'white' , { status : 'testInteraction' } , 'game_buttons' ) ) ;
188
- var state = store . getState ( ) . J5 . game_buttons . white ;
189
- expect ( state . status ) . to . equal ( 'testInteraction' ) ;
190
-
191
- var lightState = store . getState ( ) . J5 . game_light . rgb ;
192
- expect ( lightState . color ) . to . equal ( 'white' ) ;
193
- expect ( lightCallback . called ) . to . be . true ;
194
- } ) ;
195
186
} ) ;
0 commit comments