Skip to content

Commit

Permalink
fix(challenges): remove race condition from react lifecycle challenge
Browse files Browse the repository at this point in the history
  • Loading branch information
ojeytonwilliams authored and scissorsneedfoodtoo committed Aug 30, 2018
1 parent b090e8b commit a20ac56
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion challenges/03-front-end-libraries/react.json
Original file line number Diff line number Diff line change
Expand Up @@ -2575,7 +2575,7 @@
"text":
"The <code>h1</code> tag should render the <code>activeUsers</code> value from <code>MyComponent</code>&apos;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 <code>h1</code> tag should render the <code>activeUsers</code> value from <code>MyComponent</code>&apos;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 <code>h1</code> tag should render the <code>activeUsers</code> value from <code>MyComponent</code>&apos;s state.'); }; "
}
],
"solutions": [
Expand Down

0 comments on commit a20ac56

Please sign in to comment.