@@ -77,7 +77,7 @@ describe('MessagePanel', function() {
7777 DMRoomMap . makeShared ( ) ;
7878 } ) ;
7979
80- afterEach ( function ( ) {
80+ afterEach ( function ( ) {
8181 clock . uninstall ( ) ;
8282 } ) ;
8383
@@ -88,7 +88,21 @@ describe('MessagePanel', function() {
8888 events . push ( test_utils . mkMessage (
8989 {
9090 event : true , room : "!room:id" , user : "@user:id" ,
91- ts : ts0 + i * 1000 ,
91+ ts : ts0 + i * 1000 ,
92+ } ) ) ;
93+ }
94+ return events ;
95+ }
96+
97+ //Just to avoid breaking Dateseparator tests that might run at 00hrs
98+ function mkOneDayEvents ( ) {
99+ const events = [ ] ;
100+ const ts0 = Date . parse ( '09 May 2004 00:12:00 GMT' ) ;
101+ for ( let i = 0 ; i < 10 ; i ++ ) {
102+ events . push ( test_utils . mkMessage (
103+ {
104+ event : true , room : "!room:id" , user : "@user:id" ,
105+ ts : ts0 + i * 1000 ,
92106 } ) ) ;
93107 }
94108 return events ;
@@ -104,7 +118,7 @@ describe('MessagePanel', function() {
104118 let i = 0 ;
105119 events . push ( test_utils . mkMessage ( {
106120 event : true , room : "!room:id" , user : "@user:id" ,
107- ts : ts0 + ++ i * 1000 ,
121+ ts : ts0 + ++ i * 1000 ,
108122 } ) ) ;
109123
110124 for ( i = 0 ; i < 10 ; i ++ ) {
@@ -151,7 +165,7 @@ describe('MessagePanel', function() {
151165 } ,
152166 getMxcAvatarUrl : ( ) => 'mxc://avatar.url/image.png' ,
153167 } ,
154- ts : ts0 + i * 1000 ,
168+ ts : ts0 + i * 1000 ,
155169 mship : 'join' ,
156170 prevMship : 'join' ,
157171 name : 'A user' ,
@@ -251,6 +265,33 @@ describe('MessagePanel', function() {
251265 ] ;
252266 }
253267
268+ //Create a few redacted events
269+ //isRedacted just checks the redacted_because
270+ function mkRedactionEvents ( ) {
271+ const events = [ ] ;
272+ const ts0 = Date . now ( ) ;
273+ let i = 0
274+
275+ let redaction = test_utils . mkEvent ( {
276+ type : "m.room.redaction" ,
277+ event : true , room : "!room:id" , user : "@user:id" , ts : ts0 + ++ i * 1000 ,
278+ content : { } ,
279+ } ) ;
280+ let event = test_utils . mkRedactedEvent ( {
281+ type : "m.room.message" ,
282+ event : true , room : "!room:id" , user : "@user:id" ,
283+ ts : ts0 + i * 1000 ,
284+ // redacted_because: redaction This is not working at the moment
285+ } )
286+ redaction . redacts = event . event_id ;
287+
288+ events . push ( event ) ;
289+ events . push ( redaction ) ;
290+
291+ return events ;
292+
293+ }
294+
254295 function isReadMarkerVisible ( rmContainer ) {
255296 return rmContainer && rmContainer . children . length > 0 ;
256297 }
@@ -437,4 +478,34 @@ describe('MessagePanel', function() {
437478 // read marker should be hidden given props and at the last event
438479 expect ( isReadMarkerVisible ( rm ) ) . toBeFalsy ( ) ;
439480 } ) ;
481+
482+ it ( 'should render Date separators for the events' , function ( ) {
483+ const events = mkOneDayEvents ( )
484+ const res = mount (
485+ < WrappedMessagePanel
486+ className = "cls"
487+ events = { events }
488+ /> ,
489+ ) ;
490+ const Dates = res . find ( sdk . getComponent ( 'messages.DateSeparator' ) ) ;
491+
492+ expect ( Dates . length ) . toEqual ( 1 ) ;
493+
494+
495+ } )
496+
497+ it ( 'should render only one Date separator for redacted events' , function ( ) {
498+ const events = mkRedactionEvents ( )
499+ const res = mount (
500+ < WrappedMessagePanel
501+ className = "cls"
502+ events = { events }
503+ /> ,
504+ ) ;
505+ const Dates = res . find ( sdk . getComponent ( 'messages.DateSeparator' ) ) ;
506+
507+ expect ( Dates . length ) . toEqual ( 1 ) ;
508+
509+
510+ } )
440511} ) ;
0 commit comments