@@ -15,6 +15,7 @@ import { ZulipVersion } from '../../utils/zulipVersion';
15
15
16
16
import * as eg from '../../__tests__/lib/exampleData' ;
17
17
import { identityOfAccount } from '../accountMisc' ;
18
+ import { EventTypes } from '../../api/eventTypes' ;
18
19
19
20
describe ( 'accountsReducer' , ( ) => {
20
21
describe ( 'REGISTER_COMPLETE' , ( ) => {
@@ -219,4 +220,69 @@ describe('accountsReducer', () => {
219
220
) . toEqual ( prevState ) ;
220
221
} ) ;
221
222
} ) ;
223
+
224
+ describe ( 'EventTypes.realm, op update_dict' , ( ) => {
225
+ const stateWithDismissedNotice = [
226
+ { ...eg . plusReduxState . accounts [ 0 ] , lastDismissedServerPushSetupNotice : new Date ( ) } ,
227
+ ] ;
228
+ const stateWithoutDismissedNotice = [
229
+ { ...eg . plusReduxState . accounts [ 0 ] , lastDismissedServerPushSetupNotice : null } ,
230
+ ] ;
231
+
232
+ const eventCommon = { id : 0 , type : EventTypes . realm , op : 'update_dict' , property : 'default' } ;
233
+
234
+ test ( 'data.push_notifications_enabled is true, on state with dismissed notice' , ( ) => {
235
+ expect (
236
+ accountsReducer ( stateWithDismissedNotice , {
237
+ type : EVENT ,
238
+ event : { ...eventCommon , data : { push_notifications_enabled : true } } ,
239
+ } ) ,
240
+ ) . toEqual ( stateWithoutDismissedNotice ) ;
241
+ } ) ;
242
+
243
+ test ( 'data.push_notifications_enabled is true, on state without dismissed notice' , ( ) => {
244
+ expect (
245
+ accountsReducer ( stateWithoutDismissedNotice , {
246
+ type : EVENT ,
247
+ event : { ...eventCommon , data : { push_notifications_enabled : true } } ,
248
+ } ) ,
249
+ ) . toEqual ( stateWithoutDismissedNotice ) ;
250
+ } ) ;
251
+
252
+ test ( 'data.push_notifications_enabled is false, on state with dismissed notice' , ( ) => {
253
+ expect (
254
+ accountsReducer ( stateWithDismissedNotice , {
255
+ type : EVENT ,
256
+ event : { ...eventCommon , data : { push_notifications_enabled : false } } ,
257
+ } ) ,
258
+ ) . toEqual ( stateWithDismissedNotice ) ;
259
+ } ) ;
260
+
261
+ test ( 'data.push_notifications_enabled is false, on state without dismissed notice' , ( ) => {
262
+ expect (
263
+ accountsReducer ( stateWithoutDismissedNotice , {
264
+ type : EVENT ,
265
+ event : { ...eventCommon , data : { push_notifications_enabled : false } } ,
266
+ } ) ,
267
+ ) . toEqual ( stateWithoutDismissedNotice ) ;
268
+ } ) ;
269
+
270
+ test ( 'data.push_notifications_enabled is absent, on state with dismissed notice' , ( ) => {
271
+ expect (
272
+ accountsReducer ( stateWithDismissedNotice , {
273
+ type : EVENT ,
274
+ event : { ...eventCommon , data : { } } ,
275
+ } ) ,
276
+ ) . toEqual ( stateWithDismissedNotice ) ;
277
+ } ) ;
278
+
279
+ test ( 'data.push_notifications_enabled is absent, on state without dismissed notice' , ( ) => {
280
+ expect (
281
+ accountsReducer ( stateWithoutDismissedNotice , {
282
+ type : EVENT ,
283
+ event : { ...eventCommon , data : { } } ,
284
+ } ) ,
285
+ ) . toEqual ( stateWithoutDismissedNotice ) ;
286
+ } ) ;
287
+ } ) ;
222
288
} ) ;
0 commit comments