@@ -98,7 +98,7 @@ describe('useSplitClient', () => {
9898 testAttributesBinding ( Component ) ;
9999 } ) ;
100100
101- test ( 'useSplitClient must update on SDK events' , ( ) => {
101+ test ( 'must update on SDK events' , ( ) => {
102102 const outerFactory = SplitSdk ( sdkBrowser ) ;
103103 const mainClient = outerFactory . client ( ) as any ;
104104 const user2Client = outerFactory . client ( 'user_2' ) as any ;
@@ -219,7 +219,30 @@ describe('useSplitClient', () => {
219219 expect ( countNestedComponent ) . toEqual ( 4 ) ;
220220 } ) ;
221221
222- test ( 'useSplitClient must support changes in update props' , ( ) => {
222+ // Remove this test once side effects are moved to the useSplitClient effect.
223+ test ( 'must update on SDK events between the render phase (hook call) and commit phase (effect call)' , ( ) => {
224+ const outerFactory = SplitSdk ( sdkBrowser ) ;
225+ let count = 0 ;
226+
227+ render (
228+ < SplitFactory factory = { outerFactory } >
229+ { React . createElement ( ( ) => {
230+ useSplitClient ( { splitKey : 'some_user' } ) ;
231+ count ++ ;
232+
233+ // side effect in the render phase
234+ const client = outerFactory . client ( 'some_user' ) as any ;
235+ if ( ! client . __getStatus ( ) . isReady ) client . __emitter__ . emit ( Event . SDK_READY ) ;
236+
237+ return null ;
238+ } ) }
239+ </ SplitFactory >
240+ )
241+
242+ expect ( count ) . toEqual ( 2 ) ;
243+ } ) ;
244+
245+ test ( 'must support changes in update props' , ( ) => {
223246 const outerFactory = SplitSdk ( sdkBrowser ) ;
224247 const mainClient = outerFactory . client ( ) as any ;
225248
0 commit comments