@@ -2365,6 +2365,22 @@ describe('ChannelService', () => {
23652365 expect ( service . activeChannelUnreadCount ) . toBe ( 0 ) ;
23662366 } ) ;
23672367
2368+ it ( `should set last read message id to undefined if unread count is 0` , ( ) => {
2369+ const activeChannel = generateMockChannels ( ) [ 0 ] ;
2370+ activeChannel . id = 'next-active-channel' ;
2371+ activeChannel . state . read [ user . id ] = {
2372+ last_read : new Date ( ) ,
2373+ last_read_message_id : 'last-read-message-id' ,
2374+ unread_messages : 0 ,
2375+ user : user ,
2376+ } ;
2377+
2378+ service . setAsActiveChannel ( activeChannel ) ;
2379+
2380+ expect ( service . activeChannelLastReadMessageId ) . toBe ( undefined ) ;
2381+ expect ( service . activeChannelUnreadCount ) . toBe ( 0 ) ;
2382+ } ) ;
2383+
23682384 it ( 'should be able to select empty channel as active channel' , ( ) => {
23692385 const channel = generateMockChannels ( ) [ 0 ] ;
23702386 channel . id = 'new-empty-channel' ;
@@ -2569,6 +2585,18 @@ describe('ChannelService', () => {
25692585
25702586 expect ( service . activeChannelLastReadMessageId ) . toBe ( 'last-read-message' ) ;
25712587 expect ( service . activeChannelUnreadCount ) . toBe ( 12 ) ;
2588+
2589+ events$ . next ( {
2590+ eventType : 'notification.mark_unread' ,
2591+ event : {
2592+ channel_id : service . activeChannel ?. id ,
2593+ unread_messages : 0 ,
2594+ last_read_message_id : 'last-read-message' ,
2595+ } as Event < DefaultStreamChatGenerics > ,
2596+ } ) ;
2597+
2598+ expect ( service . activeChannelLastReadMessageId ) . toBe ( undefined ) ;
2599+ expect ( service . activeChannelUnreadCount ) . toBe ( 0 ) ;
25722600 } ) ;
25732601
25742602 it ( 'should halt marking the channel as read if an unread call was made in that session' , async ( ) => {
0 commit comments