@@ -24,17 +24,17 @@ describe('settingsReducer', () => {
24
24
onlineNotification : false ,
25
25
streamNotification : false ,
26
26
} ) ;
27
-
28
- const action = eg . mkActionRegisterComplete ( {
29
- enable_offline_push_notifications : true ,
30
- enable_online_push_notifications : true ,
31
- enable_stream_push_notifications : true ,
32
- user_settings : undefined ,
33
- } ) ;
34
-
35
- const actualState = settingsReducer ( prevState , action ) ;
36
-
37
- expect ( actualState ) . toMatchObject ( {
27
+ expect (
28
+ settingsReducer (
29
+ prevState ,
30
+ eg . mkActionRegisterComplete ( {
31
+ enable_offline_push_notifications : true ,
32
+ enable_online_push_notifications : true ,
33
+ enable_stream_push_notifications : true ,
34
+ user_settings : undefined ,
35
+ } ) ,
36
+ ) ,
37
+ ) . toMatchObject ( {
38
38
offlineNotification : true ,
39
39
onlineNotification : true ,
40
40
streamNotification : true ,
@@ -77,87 +77,59 @@ describe('settingsReducer', () => {
77
77
78
78
describe ( 'SET_GLOBAL_SETTINGS' , ( ) => {
79
79
test ( 'changes value of a key' , ( ) => {
80
- const action = deepFreeze ( {
81
- type : SET_GLOBAL_SETTINGS ,
82
- update : { theme : 'night' } ,
83
- } ) ;
84
-
85
- const expectedState = {
86
- ...baseState ,
87
- theme : 'night' ,
88
- } ;
89
-
90
- const actualState = settingsReducer ( baseState , action ) ;
91
-
92
- expect ( actualState ) . toEqual ( expectedState ) ;
80
+ expect (
81
+ settingsReducer (
82
+ baseState ,
83
+ deepFreeze ( { type : SET_GLOBAL_SETTINGS , update : { theme : 'night' } } ) ,
84
+ ) ,
85
+ ) . toEqual ( { ...baseState , theme : 'night' } ) ;
93
86
} ) ;
94
87
} ) ;
95
88
96
89
describe ( 'EVENT_UPDATE_GLOBAL_NOTIFICATIONS_SETTINGS' , ( ) => {
97
90
test ( 'changes offline notification setting' , ( ) => {
98
- const prevState = deepFreeze ( {
99
- ...baseState ,
100
- offlineNotification : false ,
101
- } ) ;
102
- const action = deepFreeze ( {
103
- type : EVENT_UPDATE_GLOBAL_NOTIFICATIONS_SETTINGS ,
104
- id : 0 ,
105
- notification_name : 'enable_offline_push_notifications' ,
106
- setting : true ,
107
- } ) ;
108
-
109
- const expectedState = {
110
- ...baseState ,
111
- offlineNotification : true ,
112
- } ;
113
-
114
- const actualState = settingsReducer ( prevState , action ) ;
115
-
116
- expect ( actualState ) . toEqual ( expectedState ) ;
91
+ const prevState = deepFreeze ( { ...baseState , offlineNotification : false } ) ;
92
+ expect (
93
+ settingsReducer (
94
+ prevState ,
95
+ deepFreeze ( {
96
+ type : EVENT_UPDATE_GLOBAL_NOTIFICATIONS_SETTINGS ,
97
+ id : 0 ,
98
+ notification_name : 'enable_offline_push_notifications' ,
99
+ setting : true ,
100
+ } ) ,
101
+ ) ,
102
+ ) . toEqual ( { ...baseState , offlineNotification : true } ) ;
117
103
} ) ;
118
104
119
105
test ( 'changes online notification setting' , ( ) => {
120
- const prevState = deepFreeze ( {
121
- ...baseState ,
122
- onlineNotification : false ,
123
- } ) ;
124
- const action = deepFreeze ( {
125
- type : EVENT_UPDATE_GLOBAL_NOTIFICATIONS_SETTINGS ,
126
- id : 0 ,
127
- notification_name : 'enable_online_push_notifications' ,
128
- setting : true ,
129
- } ) ;
130
-
131
- const expectedState = {
132
- ...baseState ,
133
- onlineNotification : true ,
134
- } ;
135
-
136
- const actualState = settingsReducer ( prevState , action ) ;
137
-
138
- expect ( actualState ) . toEqual ( expectedState ) ;
106
+ const prevState = deepFreeze ( { ...baseState , onlineNotification : false } ) ;
107
+ expect (
108
+ settingsReducer (
109
+ prevState ,
110
+ deepFreeze ( {
111
+ type : EVENT_UPDATE_GLOBAL_NOTIFICATIONS_SETTINGS ,
112
+ id : 0 ,
113
+ notification_name : 'enable_online_push_notifications' ,
114
+ setting : true ,
115
+ } ) ,
116
+ ) ,
117
+ ) . toEqual ( { ...baseState , onlineNotification : true } ) ;
139
118
} ) ;
140
119
141
120
test ( 'changes stream notification setting' , ( ) => {
142
- const prevState = deepFreeze ( {
143
- ...baseState ,
144
- streamNotification : false ,
145
- } ) ;
146
- const action = deepFreeze ( {
147
- type : EVENT_UPDATE_GLOBAL_NOTIFICATIONS_SETTINGS ,
148
- id : 0 ,
149
- notification_name : 'enable_stream_push_notifications' ,
150
- setting : true ,
151
- } ) ;
152
-
153
- const expectedState = {
154
- ...baseState ,
155
- streamNotification : true ,
156
- } ;
157
-
158
- const actualState = settingsReducer ( prevState , action ) ;
159
-
160
- expect ( actualState ) . toEqual ( expectedState ) ;
121
+ const prevState = deepFreeze ( { ...baseState , streamNotification : false } ) ;
122
+ expect (
123
+ settingsReducer (
124
+ prevState ,
125
+ deepFreeze ( {
126
+ type : EVENT_UPDATE_GLOBAL_NOTIFICATIONS_SETTINGS ,
127
+ id : 0 ,
128
+ notification_name : 'enable_stream_push_notifications' ,
129
+ setting : true ,
130
+ } ) ,
131
+ ) ,
132
+ ) . toEqual ( { ...baseState , streamNotification : true } ) ;
161
133
} ) ;
162
134
} ) ;
163
135
0 commit comments