@@ -370,94 +370,6 @@ describe('MessageList', () => {
370370 afterEach ( jest . clearAllMocks ) ;
371371 afterAll ( jest . restoreAllMocks ) ;
372372
373- it ( 'should keep displaying the unread messages separator when an unread channel is marked read on mount' , async ( ) => {
374- const user = generateUser ( ) ;
375- const last_read_message_id = 'X' ;
376- const lastReadMessage = generateMessage ( { id : last_read_message_id } ) ;
377- const messages = [ lastReadMessage , generateMessage ( ) , generateMessage ( ) ] ;
378- const {
379- channels : [ channel ] ,
380- client : chatClient ,
381- } = await initClientWithChannels ( {
382- channelsData : [
383- {
384- messages,
385- read : [
386- {
387- last_read : lastReadMessage . created_at . toISOString ( ) ,
388- last_read_message_id,
389- unread_messages : 2 ,
390- user,
391- } ,
392- ] ,
393- } ,
394- ] ,
395- customUser : user ,
396- } ) ;
397-
398- const markReadMock = jest
399- . spyOn ( channel , 'markRead' )
400- . mockReturnValueOnce ( markReadApi ( channel ) ) ;
401-
402- await act ( ( ) => {
403- renderComponent ( {
404- channelProps : { channel } ,
405- chatClient,
406- msgListProps : { messages } ,
407- } ) ;
408- } ) ;
409-
410- expect ( markReadMock ) . toHaveBeenCalledTimes ( 1 ) ;
411- expect ( screen . queryByText ( separatorText ) ) . toBeInTheDocument ( ) ;
412- } ) ;
413-
414- it ( 'should display unread messages separator before the first message' , async ( ) => {
415- const user = generateUser ( ) ;
416- const messages = [ generateMessage ( ) , generateMessage ( ) ] ;
417- const {
418- channels : [ channel ] ,
419- client : chatClient ,
420- } = await initClientWithChannels ( {
421- channelsData : [
422- {
423- messages,
424- read : [
425- {
426- last_read : new Date ( 1 ) . toISOString ( ) ,
427- unread_messages : messages . length ,
428- user,
429- } ,
430- ] ,
431- } ,
432- ] ,
433- customUser : user ,
434- } ) ;
435-
436- const markReadMock = jest . spyOn ( channel , 'markRead' ) . mockReturnValue ( markReadApi ( channel ) ) ;
437- const Message = ( ) => < div className = 'message-ui' /> ;
438- let container ;
439-
440- await act ( ( ) => {
441- const result = renderComponent ( {
442- channelProps : { channel, Message } ,
443- chatClient,
444- msgListProps : { messages } ,
445- } ) ;
446- container = result . container ;
447- } ) ;
448- const listItems = container . querySelectorAll ( '.str-chat__ul > *' ) ;
449- expect ( listItems ) . toHaveLength ( 4 ) ;
450- expect ( listItems [ 1 ] . firstChild ) . toMatchInlineSnapshot ( `
451- <div
452- class="str-chat__unread-messages-separator"
453- data-testid="unread-messages-separator"
454- >
455- Unread messages
456- </div>
457- ` ) ;
458- markReadMock . mockRestore ( ) ;
459- } ) ;
460-
461373 it ( 'should display unread messages separator when a channel is marked unread and remove it when marked read by markRead()' , async ( ) => {
462374 jest . useFakeTimers ( ) ;
463375 const markReadBtnTestId = 'test-mark-read' ;
0 commit comments