diff --git a/curriculum/challenges/english/03-front-end-development-libraries/react-and-redux/manage-state-locally-first.md b/curriculum/challenges/english/03-front-end-development-libraries/react-and-redux/manage-state-locally-first.md index ec7c618f3d3..ad6b98eaccb 100644 --- a/curriculum/challenges/english/03-front-end-development-libraries/react-and-redux/manage-state-locally-first.md +++ b/curriculum/challenges/english/03-front-end-development-libraries/react-and-redux/manage-state-locally-first.md @@ -39,15 +39,13 @@ assert( The `DisplayMessages` component should render a `div` containing an `h2` element, a `button` element, a `ul` element, and `li` elements as children. ```js -async () => { +() => { const mockedComponent = Enzyme.mount(React.createElement(DisplayMessages)); - const waitForIt = (fn) => - new Promise((resolve, reject) => setTimeout(() => resolve(fn()), 100)); const state = () => { mockedComponent.setState({ messages: ['__TEST__MESSAGE'] }); - return waitForIt(() => mockedComponent); + return mockedComponent; }; - const updated = await state(); + const updated = state(); assert( updated.find('div').length === 1 && updated.find('h2').length === 1 && @@ -67,18 +65,16 @@ assert(code.match(/this\.state\.messages\.map/g)); The `input` element should render the value of `input` in local state. ```js -async () => { +() => { const mockedComponent = Enzyme.mount(React.createElement(DisplayMessages)); - const waitForIt = (fn) => - new Promise((resolve, reject) => setTimeout(() => resolve(fn()), 100)); const causeChange = (c, v) => c.find('input').simulate('change', { target: { value: v } }); const testValue = '__TEST__EVENT__INPUT'; const changed = () => { causeChange(mockedComponent, testValue); - return waitForIt(() => mockedComponent); + return mockedComponent; }; - const updated = await changed(); + const updated = changed(); assert(updated.find('input').props().value === testValue); }; ``` @@ -86,19 +82,17 @@ async () => { Calling the method `handleChange` should update the `input` value in state to the current input. ```js -async () => { +() => { const mockedComponent = Enzyme.mount(React.createElement(DisplayMessages)); - const waitForIt = (fn) => - new Promise((resolve, reject) => setTimeout(() => resolve(fn()), 100)); const causeChange = (c, v) => c.find('input').simulate('change', { target: { value: v } }); const initialState = mockedComponent.state(); const testMessage = '__TEST__EVENT__MESSAGE__'; const changed = () => { causeChange(mockedComponent, testMessage); - return waitForIt(() => mockedComponent); + return mockedComponent; }; - const afterInput = await changed(); + const afterInput = changed(); assert( initialState.input === '' && afterInput.state().input === '__TEST__EVENT__MESSAGE__' @@ -109,36 +103,34 @@ async () => { Clicking the `Add message` button should call the method `submitMessage` which should add the current `input` to the `messages` array in state. ```js -async () => { +() => { const mockedComponent = Enzyme.mount(React.createElement(DisplayMessages)); - const waitForIt = (fn) => - new Promise((resolve, reject) => setTimeout(() => resolve(fn()), 100)); const causeChange = (c, v) => c.find('input').simulate('change', { target: { value: v } }); const initialState = mockedComponent.state(); const testMessage_1 = '__FIRST__MESSAGE__'; const firstChange = () => { causeChange(mockedComponent, testMessage_1); - return waitForIt(() => mockedComponent); + return mockedComponent; }; - const firstResult = await firstChange(); + const firstResult = firstChange(); const firstSubmit = () => { mockedComponent.find('button').simulate('click'); - return waitForIt(() => mockedComponent); + return mockedComponent; }; - const afterSubmit_1 = await firstSubmit(); + const afterSubmit_1 = firstSubmit(); const submitState_1 = afterSubmit_1.state(); const testMessage_2 = '__SECOND__MESSAGE__'; const secondChange = () => { causeChange(mockedComponent, testMessage_2); - return waitForIt(() => mockedComponent); + return mockedComponent; }; - const secondResult = await secondChange(); + const secondResult = secondChange(); const secondSubmit = () => { mockedComponent.find('button').simulate('click'); - return waitForIt(() => mockedComponent); + return mockedComponent; }; - const afterSubmit_2 = await secondSubmit(); + const afterSubmit_2 = secondSubmit(); const submitState_2 = afterSubmit_2.state(); assert( initialState.messages.length === 0 && @@ -152,25 +144,23 @@ async () => { The `submitMessage` method should clear the current input. ```js -async () => { +() => { const mockedComponent = Enzyme.mount(React.createElement(DisplayMessages)); - const waitForIt = (fn) => - new Promise((resolve, reject) => setTimeout(() => resolve(fn()), 100)); const causeChange = (c, v) => c.find('input').simulate('change', { target: { value: v } }); const initialState = mockedComponent.state(); const testMessage = '__FIRST__MESSAGE__'; const firstChange = () => { causeChange(mockedComponent, testMessage); - return waitForIt(() => mockedComponent); + return mockedComponent; }; - const firstResult = await firstChange(); + const firstResult = firstChange(); const firstState = firstResult.state(); const firstSubmit = () => { mockedComponent.find('button').simulate('click'); - return waitForIt(() => mockedComponent); + return mockedComponent; }; - const afterSubmit = await firstSubmit(); + const afterSubmit = firstSubmit(); const submitState = afterSubmit.state(); assert(firstState.input === testMessage && submitState.input === ''); }; diff --git a/curriculum/challenges/english/03-front-end-development-libraries/react/use-a-ternary-expression-for-conditional-rendering.md b/curriculum/challenges/english/03-front-end-development-libraries/react/use-a-ternary-expression-for-conditional-rendering.md index 33292905237..fbf6f63bbff 100644 --- a/curriculum/challenges/english/03-front-end-development-libraries/react/use-a-ternary-expression-for-conditional-rendering.md +++ b/curriculum/challenges/english/03-front-end-development-libraries/react/use-a-ternary-expression-for-conditional-rendering.md @@ -161,7 +161,7 @@ Your code should not contain any `if/else` statements. ```js assert( new RegExp(/(\s|;)if(\s|\()/).test( - Enzyme.mount(React.createElement(CheckUserAge)).instance().render.toString() + code ) === false ); ``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/step-139.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/step-139.md index 3f45adcb867..e65022a4c70 100644 --- a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/step-139.md +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/step-139.md @@ -26,13 +26,11 @@ while(i < 5) { See description above for instructions. ```js -assert( +assert.include( pick .toString() - .replace(/\s/g, '') - .includes( - 'while(numbers.length<10){if(_LPC++%2000===0&&Date.now()-_LP>1500){' - ) + .replace(/\s/g, ''), + 'while(numbers.length<10){' ); ```