@@ -40,6 +40,8 @@ test('useSplitTreatments', async () => {
4040 const user2Client = outerFactory . client ( 'user_2' ) as any ;
4141
4242 let countSplitContext = 0 , countSplitTreatments = 0 , countUseSplitTreatments = 0 , countUseSplitTreatmentsUser2 = 0 , countUseSplitTreatmentsUser2WithUpdate = 0 ;
43+ const lastUpdateSetUser2 = new Set < number > ( ) ;
44+ const lastUpdateSetUser2WithUpdate = new Set < number > ( ) ;
4345
4446 render (
4547 < SplitFactory factory = { outerFactory } >
@@ -61,13 +63,15 @@ test('useSplitTreatments', async () => {
6163 const context = useSplitTreatments ( [ 'split_test' ] , undefined , 'user_2' ) ;
6264 expect ( context . client ) . toBe ( user2Client ) ;
6365 validateTreatments ( context ) ;
66+ lastUpdateSetUser2 . add ( context . lastUpdate ) ;
6467 countUseSplitTreatmentsUser2 ++ ;
6568 return null ;
6669 } ) }
6770 { React . createElement ( ( ) => {
6871 const context = useSplitTreatments ( [ 'split_test' ] , undefined , 'user_2' , { updateOnSdkUpdate : true } ) ;
6972 expect ( context . client ) . toBe ( user2Client ) ;
7073 validateTreatments ( context ) ;
74+ lastUpdateSetUser2WithUpdate . add ( context . lastUpdate ) ;
7175 countUseSplitTreatmentsUser2WithUpdate ++ ;
7276 return null ;
7377 } ) }
@@ -96,8 +100,10 @@ test('useSplitTreatments', async () => {
96100
97101 // If useSplitTreatments uses a different client than the context one, it renders when the context renders and when the new client is ready and ready from cache.
98102 expect ( countUseSplitTreatmentsUser2 ) . toEqual ( countSplitContext + 2 ) ;
103+ expect ( lastUpdateSetUser2 . size ) . toEqual ( 3 ) ;
99104 // If it is used with `updateOnSdkUpdate: true`, it also renders when the client emits an SDK_UPDATE event.
100105 expect ( countUseSplitTreatmentsUser2WithUpdate ) . toEqual ( countSplitContext + 3 ) ;
106+ expect ( lastUpdateSetUser2WithUpdate . size ) . toEqual ( 4 ) ;
101107 expect ( user2Client . getTreatmentsWithConfig ) . toHaveBeenCalledTimes ( 5 ) ;
102108 expect ( user2Client . getTreatmentsWithConfig ) . toHaveBeenLastCalledWith ( [ 'split_test' ] , undefined ) ;
103109} ) ;
0 commit comments