@@ -252,17 +252,17 @@ describe.each([
252252 ( outerFactory as any ) . client ( ) . __emitter__ . emit ( Event . SDK_READY ) ;
253253 } ) ;
254254
255- it ( 'rerenders and re-evaluates feature flags if client changes.' , ( ) => {
255+ it ( 'rerenders and re-evaluates feature flags if client changes.' , async ( ) => {
256256 wrapper . rerender ( < Component names = { names } attributes = { attributes } splitKey = { 'otherKey' } /> ) ;
257- act ( ( ) => ( outerFactory as any ) . client ( 'otherKey' ) . __emitter__ . emit ( Event . SDK_READY ) ) ;
257+ await act ( ( ) => ( outerFactory as any ) . client ( 'otherKey' ) . __emitter__ . emit ( Event . SDK_READY ) ) ;
258258
259259 // Initial render + 2 renders (in 3 updates) -> automatic batching https://reactjs.org/blog/2022/03/29/react-v18.html#new-feature-automatic-batching
260260 expect ( renderTimes ) . toBe ( 3 ) ;
261261 expect ( outerFactory . client ( ) . getTreatmentsWithConfig ) . toBeCalledTimes ( 1 ) ;
262262 expect ( outerFactory . client ( 'otherKey' ) . getTreatmentsWithConfig ) . toBeCalledTimes ( 1 ) ;
263263 } ) ;
264264
265- it ( 'rerenders and re-evaluate splfeature flagsits when Split context changes (in both SplitFactory and SplitClient components).' , async ( ) => {
265+ it ( 'rerenders and re-evaluate feature flags when Split context changes (in both SplitFactory and SplitClient components).' , async ( ) => {
266266 // changes in SplitContext implies that either the factory, the client (user key), or its status changed, what might imply a change in treatments
267267 const outerFactory = SplitSdk ( sdkBrowser ) ;
268268 const names = [ 'split1' , 'split2' ] ;
@@ -307,8 +307,6 @@ describe.each([
307307 expect ( renderTimesComp1 ) . toBe ( 2 ) ;
308308 expect ( renderTimesComp2 ) . toBe ( 2 ) ; // updateOnSdkReadyFromCache === false, in second component
309309
310- // delay SDK events to guarantee a different lastUpdate timestamp for SplitTreatments to re-evaluate
311- await new Promise ( resolve => setTimeout ( resolve , 10 ) ) ;
312310 act ( ( ) => {
313311 ( outerFactory as any ) . client ( ) . __emitter__ . emit ( Event . SDK_READY_TIMED_OUT ) ;
314312 ( outerFactory as any ) . client ( 'user2' ) . __emitter__ . emit ( Event . SDK_READY_TIMED_OUT ) ;
@@ -317,7 +315,6 @@ describe.each([
317315 expect ( renderTimesComp1 ) . toBe ( 3 ) ;
318316 expect ( renderTimesComp2 ) . toBe ( 3 ) ;
319317
320- await new Promise ( resolve => setTimeout ( resolve , 10 ) ) ;
321318 act ( ( ) => {
322319 ( outerFactory as any ) . client ( ) . __emitter__ . emit ( Event . SDK_READY ) ;
323320 ( outerFactory as any ) . client ( 'user2' ) . __emitter__ . emit ( Event . SDK_READY ) ;
@@ -326,7 +323,6 @@ describe.each([
326323 expect ( renderTimesComp1 ) . toBe ( 3 ) ; // updateOnSdkReady === false, in first component
327324 expect ( renderTimesComp2 ) . toBe ( 4 ) ;
328325
329- await new Promise ( resolve => setTimeout ( resolve , 10 ) ) ;
330326 act ( ( ) => {
331327 ( outerFactory as any ) . client ( ) . __emitter__ . emit ( Event . SDK_UPDATE ) ;
332328 ( outerFactory as any ) . client ( 'user2' ) . __emitter__ . emit ( Event . SDK_UPDATE ) ;
0 commit comments