File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
package/src/components/Channel/__tests__ Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -356,7 +356,7 @@ describe('Channel initial load useEffect', () => {
356356 cleanup ( ) ;
357357 } ) ;
358358
359- it ( 'should not call channel.watch if channel is not initialized ' , async ( ) => {
359+ it ( 'should still call channel.watch if we are online and DB channels are loaded ' , async ( ) => {
360360 const messages = Array . from ( { length : 10 } , ( _ , i ) => generateMessage ( { id : i } ) ) ;
361361 const mockedChannel = generateChannelResponse ( {
362362 messages,
@@ -366,13 +366,18 @@ describe('Channel initial load useEffect', () => {
366366 const channel = chatClient . channel ( 'messaging' , mockedChannel . id ) ;
367367 await channel . watch ( ) ;
368368 channel . offlineMode = true ;
369- channel . state = channelInitialState ;
369+ channel . state = {
370+ ...channelInitialState ,
371+ messagePagination : {
372+ hasPrev : true ,
373+ } ,
374+ } ;
370375 const watchSpy = jest . fn ( ) ;
371376 channel . watch = watchSpy ;
372377
373378 renderComponent ( { channel } ) ;
374379
375- await waitFor ( ( ) => expect ( watchSpy ) . not . toHaveBeenCalled ( ) ) ;
380+ await waitFor ( ( ) => expect ( watchSpy ) . toHaveBeenCalledTimes ( 1 ) ) ;
376381 } ) ;
377382
378383 it ( "should call channel.watch if channel is initialized and it's not in offline mode" , async ( ) => {
You can’t perform that action at this time.
0 commit comments