From a20ac56f35f930c2603248827a0d13349cbfa544 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Fri, 24 Aug 2018 16:50:32 +0200 Subject: [PATCH] fix(challenges): remove race condition from react lifecycle challenge --- challenges/03-front-end-libraries/react.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/challenges/03-front-end-libraries/react.json b/challenges/03-front-end-libraries/react.json index c7707f1534..33ae46eda9 100644 --- a/challenges/03-front-end-libraries/react.json +++ b/challenges/03-front-end-libraries/react.json @@ -2575,7 +2575,7 @@ "text": "The h1 tag should render the activeUsers value from MyComponent's state.", "testString": - "async () => { const waitForIt = (fn) => new Promise((resolve, reject) => setTimeout(() => resolve(fn()), 250)); const mockedComponent = Enzyme.mount(React.createElement(MyComponent)); const first = () => { mockedComponent.setState({ activeUsers: 1237 }); return waitForIt(() => mockedComponent.find('h1').text()); }; const second = () => { mockedComponent.setState({ activeUsers: 1000 }); return waitForIt(() => mockedComponent.find('h1').text()); }; const firstValue = await first(); const secondValue = await second(); assert(new RegExp('1237').test(firstValue) && new RegExp('1000').test(secondValue), 'The h1 tag should render the activeUsers value from MyComponent's state.'); }; " + "async () => { const mockedComponent = Enzyme.mount(React.createElement(MyComponent)); const first = () => { mockedComponent.setState({ activeUsers: 1237 }); return mockedComponent.find('h1').text(); }; const second = () => { mockedComponent.setState({ activeUsers: 1000 }); return mockedComponent.find('h1').text(); }; assert(new RegExp('1237').test(first()) && new RegExp('1000').test(second()), 'The h1 tag should render the activeUsers value from MyComponent's state.'); }; " } ], "solutions": [