@@ -17,7 +17,6 @@ import {
17
17
} from '../../utils/narrow' ;
18
18
import {
19
19
MESSAGE_FETCH_ERROR ,
20
- MESSAGE_FETCH_COMPLETE ,
21
20
EVENT_MESSAGE_DELETE ,
22
21
EVENT_UPDATE_MESSAGE_FLAGS ,
23
22
} from '../../actionConstants' ;
@@ -361,17 +360,11 @@ describe('narrowsReducer', () => {
361
360
test ( 'if no messages returned still create the key in state' , ( ) => {
362
361
const initialState = Immutable . Map ( [ [ HOME_NARROW_STR , [ 1 , 2 , 3 ] ] ] ) ;
363
362
364
- const action = deepFreeze ( {
365
- type : MESSAGE_FETCH_COMPLETE ,
366
- anchor : 2 ,
363
+ const action = {
364
+ ...eg . action . message_fetch_complete ,
367
365
narrow : pm1to1NarrowFromUser ( eg . otherUser ) ,
368
366
messages : [ ] ,
369
- numBefore : 100 ,
370
- numAfter : 100 ,
371
- foundNewest : false ,
372
- foundOldest : false ,
373
- ownUserId : eg . selfUser . user_id ,
374
- } ) ;
367
+ } ;
375
368
376
369
const expectedState = Immutable . Map ( [
377
370
[ HOME_NARROW_STR , [ 1 , 2 , 3 ] ] ,
@@ -386,21 +379,16 @@ describe('narrowsReducer', () => {
386
379
test ( 'no duplicate messages' , ( ) => {
387
380
const initialState = Immutable . Map ( [ [ HOME_NARROW_STR , [ 1 , 2 , 3 ] ] ] ) ;
388
381
389
- const action = deepFreeze ( {
390
- type : MESSAGE_FETCH_COMPLETE ,
391
- anchor : 2 ,
382
+ const action = {
383
+ ...eg . action . message_fetch_complete ,
392
384
narrow : HOME_NARROW ,
385
+ anchor : 2 ,
393
386
messages : [
394
387
eg . streamMessage ( { id : 2 } ) ,
395
388
eg . streamMessage ( { id : 3 } ) ,
396
389
eg . streamMessage ( { id : 4 } ) ,
397
390
] ,
398
- numBefore : 100 ,
399
- numAfter : 100 ,
400
- foundNewest : false ,
401
- foundOldest : false ,
402
- ownUserId : eg . selfUser . user_id ,
403
- } ) ;
391
+ } ;
404
392
405
393
const expectedState = Immutable . Map ( [ [ HOME_NARROW_STR , [ 1 , 2 , 3 , 4 ] ] ] ) ;
406
394
@@ -413,20 +401,15 @@ describe('narrowsReducer', () => {
413
401
test ( 'added messages are sorted by id' , ( ) => {
414
402
const initialState = Immutable . Map ( [ [ HOME_NARROW_STR , [ 1 , 2 ] ] ] ) ;
415
403
416
- const action = deepFreeze ( {
417
- type : MESSAGE_FETCH_COMPLETE ,
418
- anchor : 2 ,
404
+ const action = {
405
+ ...eg . action . message_fetch_complete ,
419
406
narrow : HOME_NARROW ,
407
+ anchor : 2 ,
420
408
messages : [
421
409
eg . streamMessage ( { id : 3 , timestamp : 2 } ) ,
422
410
eg . streamMessage ( { id : 4 , timestamp : 1 } ) ,
423
411
] ,
424
- numBefore : 100 ,
425
- numAfter : 100 ,
426
- foundNewest : false ,
427
- foundOldest : false ,
428
- ownUserId : eg . selfUser . user_id ,
429
- } ) ;
412
+ } ;
430
413
431
414
const expectedState = Immutable . Map ( [ [ HOME_NARROW_STR , [ 1 , 2 , 3 , 4 ] ] ] ) ;
432
415
@@ -439,20 +422,15 @@ describe('narrowsReducer', () => {
439
422
test ( 'when anchor is FIRST_UNREAD_ANCHOR previous messages are replaced' , ( ) => {
440
423
const initialState = Immutable . Map ( [ [ HOME_NARROW_STR , [ 1 , 2 ] ] ] ) ;
441
424
442
- const action = deepFreeze ( {
443
- anchor : FIRST_UNREAD_ANCHOR ,
444
- type : MESSAGE_FETCH_COMPLETE ,
425
+ const action = {
426
+ ...eg . action . message_fetch_complete ,
445
427
narrow : HOME_NARROW ,
428
+ anchor : FIRST_UNREAD_ANCHOR ,
446
429
messages : [
447
430
eg . streamMessage ( { id : 3 , timestamp : 2 } ) ,
448
431
eg . streamMessage ( { id : 4 , timestamp : 1 } ) ,
449
432
] ,
450
- numBefore : 100 ,
451
- numAfter : 100 ,
452
- foundNewest : false ,
453
- foundOldest : false ,
454
- ownUserId : eg . selfUser . user_id ,
455
- } ) ;
433
+ } ;
456
434
457
435
const expectedState = Immutable . Map ( [ [ HOME_NARROW_STR , [ 3 , 4 ] ] ] ) ;
458
436
@@ -464,20 +442,15 @@ describe('narrowsReducer', () => {
464
442
test ( 'when anchor is LAST_MESSAGE_ANCHOR previous messages are replaced' , ( ) => {
465
443
const initialState = Immutable . Map ( [ [ HOME_NARROW_STR , [ 1 , 2 ] ] ] ) ;
466
444
467
- const action = deepFreeze ( {
468
- anchor : LAST_MESSAGE_ANCHOR ,
469
- type : MESSAGE_FETCH_COMPLETE ,
445
+ const action = {
446
+ ...eg . action . message_fetch_complete ,
470
447
narrow : HOME_NARROW ,
448
+ anchor : LAST_MESSAGE_ANCHOR ,
471
449
messages : [
472
450
eg . streamMessage ( { id : 3 , timestamp : 2 } ) ,
473
451
eg . streamMessage ( { id : 4 , timestamp : 1 } ) ,
474
452
] ,
475
- numBefore : 100 ,
476
- numAfter : 0 ,
477
- foundNewest : true ,
478
- foundOldest : false ,
479
- ownUserId : eg . selfUser . user_id ,
480
- } ) ;
453
+ } ;
481
454
482
455
const expectedState = Immutable . Map ( [ [ HOME_NARROW_STR , [ 3 , 4 ] ] ] ) ;
483
456
@@ -489,10 +462,7 @@ describe('narrowsReducer', () => {
489
462
test ( 'if fetched messages are from a search narrow, ignore them' , ( ) => {
490
463
const initialState = Immutable . Map ( [ [ HOME_NARROW_STR , [ 1 , 2 ] ] ] ) ;
491
464
492
- const action = deepFreeze ( {
493
- ...eg . action . message_fetch_complete ,
494
- narrow : SEARCH_NARROW ( 'some query' ) ,
495
- } ) ;
465
+ const action = { ...eg . action . message_fetch_complete , narrow : SEARCH_NARROW ( 'some query' ) } ;
496
466
497
467
const newState = narrowsReducer ( initialState , action ) ;
498
468
0 commit comments