@@ -14,7 +14,7 @@ import userGroupsReducer from '../userGroupsReducer';
14
14
describe ( 'userGroupsReducer' , ( ) => {
15
15
describe ( 'REGISTER_COMPLETE' , ( ) => {
16
16
test ( 'when data is provided init state with it' , ( ) => {
17
- const initialState = deepFreeze ( [ ] ) ;
17
+ const prevState = deepFreeze ( [ ] ) ;
18
18
const action = deepFreeze ( {
19
19
type : REGISTER_COMPLETE ,
20
20
data : {
@@ -28,7 +28,7 @@ describe('userGroupsReducer', () => {
28
28
} ,
29
29
} ) ;
30
30
31
- const actualState = userGroupsReducer ( initialState , action ) ;
31
+ const actualState = userGroupsReducer ( prevState , action ) ;
32
32
33
33
expect ( actualState ) . toEqual ( [
34
34
{
@@ -40,22 +40,22 @@ describe('userGroupsReducer', () => {
40
40
} ) ;
41
41
42
42
test ( 'when no data is given reset state' , ( ) => {
43
- const initialState = deepFreeze ( [ [ 'stream' ] , [ 'topic' ] ] ) ;
43
+ const prevState = deepFreeze ( [ [ 'stream' ] , [ 'topic' ] ] ) ;
44
44
const action = deepFreeze ( {
45
45
type : REGISTER_COMPLETE ,
46
46
data : { } ,
47
47
} ) ;
48
48
const expectedState = [ ] ;
49
49
50
- const actualState = userGroupsReducer ( initialState , action ) ;
50
+ const actualState = userGroupsReducer ( prevState , action ) ;
51
51
52
52
expect ( actualState ) . toEqual ( expectedState ) ;
53
53
} ) ;
54
54
} ) ;
55
55
56
56
describe ( 'ACCOUNT_SWITCH' , ( ) => {
57
57
test ( 'resets state to initial state' , ( ) => {
58
- const initialState = deepFreeze ( [
58
+ const prevState = deepFreeze ( [
59
59
{
60
60
id : 1 ,
61
61
name : 'Some Group' ,
@@ -70,15 +70,15 @@ describe('userGroupsReducer', () => {
70
70
71
71
const expectedState = [ ] ;
72
72
73
- const actualState = userGroupsReducer ( initialState , action ) ;
73
+ const actualState = userGroupsReducer ( prevState , action ) ;
74
74
75
75
expect ( actualState ) . toEqual ( expectedState ) ;
76
76
} ) ;
77
77
} ) ;
78
78
79
79
describe ( 'EVENT_USER_GROUP_ADD' , ( ) => {
80
80
test ( 'adds a user group to the state' , ( ) => {
81
- const initialState = deepFreeze ( [ ] ) ;
81
+ const prevState = deepFreeze ( [ ] ) ;
82
82
const group = {
83
83
id : 1 ,
84
84
name : 'Some Group' ,
@@ -93,29 +93,29 @@ describe('userGroupsReducer', () => {
93
93
94
94
const expectedState = [ group ] ;
95
95
96
- const actualState = userGroupsReducer ( initialState , action ) ;
96
+ const actualState = userGroupsReducer ( prevState , action ) ;
97
97
98
98
expect ( actualState ) . toEqual ( expectedState ) ;
99
99
} ) ;
100
100
} ) ;
101
101
102
102
describe ( 'EVENT_USER_GROUP_REMOVE' , ( ) => {
103
103
test ( 'if user group does not exist state does not change' , ( ) => {
104
- const initialState = deepFreeze ( [ ] ) ;
104
+ const prevState = deepFreeze ( [ ] ) ;
105
105
const action = deepFreeze ( {
106
106
type : EVENT_USER_GROUP_REMOVE ,
107
107
op : 'remove' ,
108
108
group_id : 1 ,
109
109
} ) ;
110
110
const expectedState = [ ] ;
111
111
112
- const actualState = userGroupsReducer ( initialState , action ) ;
112
+ const actualState = userGroupsReducer ( prevState , action ) ;
113
113
114
114
expect ( actualState ) . toEqual ( expectedState ) ;
115
115
} ) ;
116
116
117
117
test ( 'adds a user group to the state' , ( ) => {
118
- const initialState = deepFreeze ( [
118
+ const prevState = deepFreeze ( [
119
119
{
120
120
id : 1 ,
121
121
name : 'Some group' ,
@@ -138,15 +138,15 @@ describe('userGroupsReducer', () => {
138
138
} ,
139
139
] ;
140
140
141
- const actualState = userGroupsReducer ( initialState , action ) ;
141
+ const actualState = userGroupsReducer ( prevState , action ) ;
142
142
143
143
expect ( actualState ) . toEqual ( expectedState ) ;
144
144
} ) ;
145
145
} ) ;
146
146
147
147
describe ( 'EVENT_USER_GROUP_UPDATE' , ( ) => {
148
148
test ( 'if user group does not exist state does not change' , ( ) => {
149
- const initialState = deepFreeze ( [ ] ) ;
149
+ const prevState = deepFreeze ( [ ] ) ;
150
150
const action = deepFreeze ( {
151
151
type : EVENT_USER_GROUP_UPDATE ,
152
152
op : 'update' ,
@@ -155,13 +155,13 @@ describe('userGroupsReducer', () => {
155
155
} ) ;
156
156
const expectedState = [ ] ;
157
157
158
- const actualState = userGroupsReducer ( initialState , action ) ;
158
+ const actualState = userGroupsReducer ( prevState , action ) ;
159
159
160
160
expect ( actualState ) . toEqual ( expectedState ) ;
161
161
} ) ;
162
162
163
163
test ( 'updates an existing user group with supplied new values' , ( ) => {
164
- const initialState = deepFreeze ( [
164
+ const prevState = deepFreeze ( [
165
165
{
166
166
id : 1 ,
167
167
name : 'Some group' ,
@@ -188,15 +188,15 @@ describe('userGroupsReducer', () => {
188
188
} ,
189
189
] ;
190
190
191
- const actualState = userGroupsReducer ( initialState , action ) ;
191
+ const actualState = userGroupsReducer ( prevState , action ) ;
192
192
193
193
expect ( actualState ) . toEqual ( expectedState ) ;
194
194
} ) ;
195
195
} ) ;
196
196
197
197
describe ( 'EVENT_USER_GROUP_ADD_MEMBERS' , ( ) => {
198
198
test ( 'if user group does not exist state does not change' , ( ) => {
199
- const initialState = deepFreeze ( [ ] ) ;
199
+ const prevState = deepFreeze ( [ ] ) ;
200
200
const action = deepFreeze ( {
201
201
type : EVENT_USER_GROUP_ADD_MEMBERS ,
202
202
op : 'add_members' ,
@@ -205,13 +205,13 @@ describe('userGroupsReducer', () => {
205
205
} ) ;
206
206
const expectedState = [ ] ;
207
207
208
- const actualState = userGroupsReducer ( initialState , action ) ;
208
+ const actualState = userGroupsReducer ( prevState , action ) ;
209
209
210
210
expect ( actualState ) . toEqual ( expectedState ) ;
211
211
} ) ;
212
212
213
213
test ( 'updates an existing user group with supplied new members' , ( ) => {
214
- const initialState = deepFreeze ( [
214
+ const prevState = deepFreeze ( [
215
215
{
216
216
id : 1 ,
217
217
name : 'Some group' ,
@@ -232,15 +232,15 @@ describe('userGroupsReducer', () => {
232
232
} ,
233
233
] ;
234
234
235
- const actualState = userGroupsReducer ( initialState , action ) ;
235
+ const actualState = userGroupsReducer ( prevState , action ) ;
236
236
237
237
expect ( actualState ) . toEqual ( expectedState ) ;
238
238
} ) ;
239
239
} ) ;
240
240
241
241
describe ( 'EVENT_USER_GROUP_REMOVE_MEMBERS' , ( ) => {
242
242
test ( 'if user group does not exist state does not change' , ( ) => {
243
- const initialState = deepFreeze ( [ ] ) ;
243
+ const prevState = deepFreeze ( [ ] ) ;
244
244
const action = deepFreeze ( {
245
245
type : EVENT_USER_GROUP_REMOVE_MEMBERS ,
246
246
op : 'remove_members' ,
@@ -249,13 +249,13 @@ describe('userGroupsReducer', () => {
249
249
} ) ;
250
250
const expectedState = [ ] ;
251
251
252
- const actualState = userGroupsReducer ( initialState , action ) ;
252
+ const actualState = userGroupsReducer ( prevState , action ) ;
253
253
254
254
expect ( actualState ) . toEqual ( expectedState ) ;
255
255
} ) ;
256
256
257
257
test ( 'removes members from an existing user group' , ( ) => {
258
- const initialState = deepFreeze ( [
258
+ const prevState = deepFreeze ( [
259
259
{
260
260
id : 1 ,
261
261
name : 'Some group' ,
@@ -286,7 +286,7 @@ describe('userGroupsReducer', () => {
286
286
} ,
287
287
] ;
288
288
289
- const actualState = userGroupsReducer ( initialState , action ) ;
289
+ const actualState = userGroupsReducer ( prevState , action ) ;
290
290
291
291
expect ( actualState ) . toEqual ( expectedState ) ;
292
292
} ) ;
0 commit comments