@@ -55,11 +55,71 @@ describe('SendbirdProvider', () => {
5555 expect ( mockActions . connect ) . toHaveBeenCalledWith (
5656 expect . objectContaining ( {
5757 appId : 'mockAppId' ,
58+ isNewApp : true ,
5859 userId : 'mockUserId' ,
5960 } ) ,
6061 ) ;
6162 } ) ;
6263
64+ it ( 'should preserve the legacy isNewApp behavior across app and user changes' , ( ) => {
65+ const { rerender } = render (
66+ < SendbirdContextProvider appId = "mockAppId" userId = "mockUserId" >
67+ < div data-testid = "child" > Child Component</ div >
68+ </ SendbirdContextProvider > ,
69+ ) ;
70+
71+ expect ( mockActions . connect ) . toHaveBeenNthCalledWith ( 1 , expect . objectContaining ( {
72+ appId : 'mockAppId' ,
73+ isNewApp : true ,
74+ userId : 'mockUserId' ,
75+ } ) ) ;
76+
77+ rerender (
78+ < SendbirdContextProvider appId = "mockAppId" userId = "nextUserId" >
79+ < div data-testid = "child" > Child Component</ div >
80+ </ SendbirdContextProvider > ,
81+ ) ;
82+
83+ expect ( mockActions . connect ) . toHaveBeenNthCalledWith ( 2 , expect . objectContaining ( {
84+ appId : 'mockAppId' ,
85+ isNewApp : false ,
86+ userId : 'nextUserId' ,
87+ } ) ) ;
88+
89+ rerender (
90+ < SendbirdContextProvider appId = "nextAppId" userId = "nextUserId" >
91+ < div data-testid = "child" > Child Component</ div >
92+ </ SendbirdContextProvider > ,
93+ ) ;
94+
95+ expect ( mockActions . connect ) . toHaveBeenNthCalledWith ( 3 , expect . objectContaining ( {
96+ appId : 'nextAppId' ,
97+ isNewApp : true ,
98+ userId : 'nextUserId' ,
99+ } ) ) ;
100+ } ) ;
101+
102+ it ( 'should reconnect on StrictMode remount with the same appId and userId' , ( ) => {
103+ render (
104+ < React . StrictMode >
105+ < SendbirdContextProvider appId = "mockAppId" userId = "mockUserId" >
106+ < div data-testid = "child" > Child Component</ div >
107+ </ SendbirdContextProvider >
108+ </ React . StrictMode > ,
109+ ) ;
110+
111+ expect ( mockActions . connect ) . toHaveBeenCalledTimes ( 2 ) ;
112+ expect ( mockActions . connect ) . toHaveBeenNthCalledWith ( 1 , expect . objectContaining ( {
113+ appId : 'mockAppId' ,
114+ isNewApp : true ,
115+ userId : 'mockUserId' ,
116+ } ) ) ;
117+ expect ( mockActions . connect ) . toHaveBeenNthCalledWith ( 2 , expect . objectContaining ( {
118+ appId : 'mockAppId' ,
119+ userId : 'mockUserId' ,
120+ } ) ) ;
121+ } ) ;
122+
63123 it ( 'should call disconnect on unmount' , ( ) => {
64124 const { unmount } = render (
65125 < SendbirdContextProvider appId = "mockAppId" userId = "mockUserId" >
0 commit comments