@@ -334,7 +334,11 @@ describe('Channel', () => {
334334 it ( 'should watch the current channel on mount' , async ( ) => {
335335 const watchSpy = jest . spyOn ( channel , 'watch' ) ;
336336
337- await renderComponent ( { channel, chatClient } ) ;
337+ await renderComponent ( {
338+ channel,
339+ channelQueryOptions : { messages : { limit : 25 } } ,
340+ chatClient,
341+ } ) ;
338342
339343 await waitFor ( ( ) => {
340344 expect ( watchSpy ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -380,9 +384,12 @@ describe('Channel', () => {
380384 ] ) ;
381385 let hasMore ;
382386 await act ( ( ) => {
383- renderComponent ( { channel, chatClient } , ( { hasMore : contextHasMore } ) => {
384- hasMore = contextHasMore ;
385- } ) ;
387+ renderComponent (
388+ { channel, channelQueryOptions : { messages : { limit : 25 } } , chatClient } ,
389+ ( { hasMore : contextHasMore } ) => {
390+ hasMore = contextHasMore ;
391+ } ,
392+ ) ;
386393 } ) ;
387394
388395 await waitFor ( ( ) => {
@@ -395,9 +402,12 @@ describe('Channel', () => {
395402 queryChannelWithNewMessages ( Array . from ( { length : 25 } , generateMessage ) , channel ) ,
396403 ] ) ;
397404 let hasMore ;
398- await renderComponent ( { channel, chatClient } , ( { hasMore : contextHasMore } ) => {
399- hasMore = contextHasMore ;
400- } ) ;
405+ await renderComponent (
406+ { channel, channelQueryOptions : { messages : { limit : 25 } } , chatClient } ,
407+ ( { hasMore : contextHasMore } ) => {
408+ hasMore = contextHasMore ;
409+ } ,
410+ ) ;
401411
402412 await waitFor ( ( ) => {
403413 expect ( hasMore ) . toBe ( true ) ;
@@ -761,15 +771,21 @@ describe('Channel', () => {
761771 const limit = 10 ;
762772 it ( "should initiate the hasMore flag with the current message set's pagination hasPrev value" , async ( ) => {
763773 let hasMore ;
764- await renderComponent ( { channel, chatClient } , ( { hasMore : hasMoreCtx } ) => {
765- hasMore = hasMoreCtx ;
766- } ) ;
774+ await renderComponent (
775+ { channel, channelQueryOptions : { messages : { limit : 25 } } , chatClient } ,
776+ ( { hasMore : hasMoreCtx } ) => {
777+ hasMore = hasMoreCtx ;
778+ } ,
779+ ) ;
767780 expect ( hasMore ) . toBe ( true ) ;
768781
769782 channel . state . messageSets [ 0 ] . pagination . hasPrev = false ;
770- await renderComponent ( { channel, chatClient } , ( { hasMore : hasMoreCtx } ) => {
771- hasMore = hasMoreCtx ;
772- } ) ;
783+ await renderComponent (
784+ { channel, channelQueryOptions : { messages : { limit : 25 } } , chatClient } ,
785+ ( { hasMore : hasMoreCtx } ) => {
786+ hasMore = hasMoreCtx ;
787+ } ,
788+ ) ;
773789 expect ( hasMore ) . toBe ( false ) ;
774790 } ) ;
775791 it ( 'should be able to load more messages' , async ( ) => {
@@ -779,7 +795,7 @@ describe('Channel', () => {
779795 const newMessages = [ generateMessage ( ) ] ;
780796
781797 await renderComponent (
782- { channel, chatClient } ,
798+ { channel, channelQueryOptions : { messages : { limit : 25 } } , chatClient } ,
783799 ( { loadMore, messages : contextMessages } ) => {
784800 if ( ! contextMessages . find ( ( message ) => message . id === newMessages [ 0 ] . id ) ) {
785801 // Our new message is not yet passed as part of channel context. Call loadMore and mock API response to include it.
@@ -837,7 +853,7 @@ describe('Channel', () => {
837853 . fill ( null )
838854 . map ( ( ) => generateMessage ( ) ) ;
839855 await renderComponent (
840- { channel, chatClient } ,
856+ { channel, channelQueryOptions : { messages : { limit : 25 } } , chatClient } ,
841857 ( { hasMore, loadMore, messages : contextMessages } ) => {
842858 if ( ! contextMessages . some ( ( message ) => message . id === newMessages [ 0 ] . id ) ) {
843859 // Our new messages are not yet passed as part of channel context. Call loadMore and mock API response to include it.
@@ -859,12 +875,15 @@ describe('Channel', () => {
859875 const queryPromise = new Promise ( ( ) => { } ) ;
860876 let isLoadingMore = false ;
861877
862- await renderComponent ( { channel, chatClient } , ( { loadingMore, loadMore } ) => {
863- // return a promise that hasn't resolved yet, so loadMore will be stuck in the 'await' part of the function
864- jest . spyOn ( channel , 'query' ) . mockImplementationOnce ( ( ) => queryPromise ) ;
865- loadMore ( ) ;
866- isLoadingMore = loadingMore ;
867- } ) ;
878+ await renderComponent (
879+ { channel, channelQueryOptions : { messages : { limit : 25 } } , chatClient } ,
880+ ( { loadingMore, loadMore } ) => {
881+ // return a promise that hasn't resolved yet, so loadMore will be stuck in the 'await' part of the function
882+ jest . spyOn ( channel , 'query' ) . mockImplementationOnce ( ( ) => queryPromise ) ;
883+ loadMore ( ) ;
884+ isLoadingMore = loadingMore ;
885+ } ,
886+ ) ;
868887 await waitFor ( ( ) => expect ( isLoadingMore ) . toBe ( true ) ) ;
869888 } ) ;
870889
@@ -912,7 +931,7 @@ describe('Channel', () => {
912931 let queryNextPageSpy ;
913932 let contextMessageCount ;
914933 await renderComponent (
915- { channel, chatClient } ,
934+ { channel, channelQueryOptions : { messages : { limit : 25 } } , chatClient } ,
916935 ( { loadMore, messages : contextMessages } ) => {
917936 queryNextPageSpy = jest . spyOn ( channel , 'query' ) ;
918937 contextMessageCount = contextMessages . length ;
@@ -935,9 +954,9 @@ describe('Channel', () => {
935954 expect ( chatClient . axiosInstance . post . mock . calls [ 1 ] [ 1 ] ) . toMatchObject (
936955 expect . objectContaining ( {
937956 data : { } ,
938- messages : { id_lt : firstPageMessages [ 0 ] . id , limit : 100 } ,
957+ messages : { id_lt : firstPageMessages [ 0 ] . id , limit : 25 } ,
939958 state : true ,
940- watchers : { limit : 100 } ,
959+ watchers : { limit : 25 } ,
941960 } ) ,
942961 ) ;
943962 expect ( contextMessageCount ) . toBe (
0 commit comments