File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -240,4 +240,28 @@ describe('Experiment', function () {
240240 expect ( wrapper . find ( `#variant-${ chosenVariant } ` ) . exists ( ) ) . toBe ( true ) ;
241241 }
242242 } ) ;
243+
244+ it ( 'should not not cause an infinite rendering loop when calling setState' , ( ) => {
245+ const userIdentifier = UUID ( ) ;
246+ const experimentName = UUID ( ) ;
247+ const spy = jest . spyOn ( console , 'error' ) ;
248+ const App = ( ) => {
249+ const [ counter , setCounter ] = React . useState ( 0 ) ;
250+ return (
251+ < >
252+ < Experiment name = { experimentName } userIdentifier = { userIdentifier } >
253+ < Variant name = "A" > A</ Variant >
254+ < Variant name = "B" > B</ Variant >
255+ </ Experiment >
256+
257+ < button onClick = { ( ) => setCounter ( counter + 1 ) } >
258+ Re-render ({ counter } )
259+ </ button >
260+ </ >
261+ ) ;
262+ } ;
263+ const wrapper = mount ( < App /> ) ;
264+ wrapper . find ( 'button' ) . simulate ( 'click' ) ;
265+ expect ( spy ) . not . toHaveBeenCalled ( ) ;
266+ } ) ;
243267} ) ;
You can’t perform that action at this time.
0 commit comments