From f1391868c007809309016b51bc5baef563d28c9a Mon Sep 17 00:00:00 2001 From: Paolo Moretti Date: Sat, 29 May 2021 20:21:59 +0200 Subject: [PATCH] Add test for https://github.com/marvelapp/react-ab-test/issues/24 --- test/browser/experiment.test.jsx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/browser/experiment.test.jsx b/test/browser/experiment.test.jsx index f6f4a5f..3c446d6 100644 --- a/test/browser/experiment.test.jsx +++ b/test/browser/experiment.test.jsx @@ -240,4 +240,28 @@ describe('Experiment', function () { expect(wrapper.find(`#variant-${chosenVariant}`).exists()).toBe(true); } }); + + it('should not not cause an infinite rendering loop when calling setState', () => { + const userIdentifier = UUID(); + const experimentName = UUID(); + const spy = jest.spyOn(console, 'error'); + const App = () => { + const [counter, setCounter] = React.useState(0); + return ( + <> + + A + B + + + + + ); + }; + const wrapper = mount(); + wrapper.find('button').simulate('click'); + expect(spy).not.toHaveBeenCalled(); + }); });