From 9610c2729f911f44743ffd602341fc4a032c5177 Mon Sep 17 00:00:00 2001 From: Chaitanya Date: Wed, 18 Apr 2018 00:32:57 +0530 Subject: [PATCH] Fix to tests messages (#17059) In https://beta.freecodecamp.org/en/challenges/react/write-a-simple-counter challenge code is referring to Component Counter but messages are referring to myComponent --- challenges/03-front-end-libraries/react.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/challenges/03-front-end-libraries/react.json b/challenges/03-front-end-libraries/react.json index 4586115d85..54ab9f8568 100644 --- a/challenges/03-front-end-libraries/react.json +++ b/challenges/03-front-end-libraries/react.json @@ -1521,8 +1521,8 @@ } }, "tests": [ - "assert((() => { const mockedComponent = Enzyme.mount(React.createElement(Counter)); return (mockedComponent.find('.inc').text() === 'Increment!' && mockedComponent.find('.dec').text() === 'Decrement!' && mockedComponent.find('.reset').text() === 'Reset'); })(), 'message: MyComponent should return a div element which contains three buttons with text content in this order Increment!, Decrement!, Reset.');", - "assert.strictEqual(Enzyme.mount(React.createElement(Counter)).state('count'), 0, 'message: The state of MyComponent should initialize with a count property set to 0.');", + "assert((() => { const mockedComponent = Enzyme.mount(React.createElement(Counter)); return (mockedComponent.find('.inc').text() === 'Increment!' && mockedComponent.find('.dec').text() === 'Decrement!' && mockedComponent.find('.reset').text() === 'Reset'); })(), 'message: Counter should return a div element which contains three buttons with text content in this order Increment!, Decrement!, Reset.');", + "assert.strictEqual(Enzyme.mount(React.createElement(Counter)).state('count'), 0, 'message: The state of Counter should initialize with a count property set to 0.');", "async () => { const waitForIt = (fn) => new Promise((resolve, reject) => setTimeout(() => resolve(fn()), 250)); const mockedComponent = Enzyme.mount(React.createElement(Counter)); const first = () => { mockedComponent.setState({ count: 0 }); return waitForIt(() => mockedComponent.state('count')); }; const second = () => { mockedComponent.find('.inc').simulate('click'); return waitForIt(() => mockedComponent.state('count')); }; const firstValue = await first(); const secondValue = await second(); assert(firstValue === 0 && secondValue === 1, 'message: Clicking the increment button should increment the count by 1.'); }; ", "async () => { const waitForIt = (fn) => new Promise((resolve, reject) => setTimeout(() => resolve(fn()), 250)); const mockedComponent = Enzyme.mount(React.createElement(Counter)); const first = () => { mockedComponent.setState({ count: 0 }); return waitForIt(() => mockedComponent.state('count')); }; const second = () => { mockedComponent.find('.dec').simulate('click'); return waitForIt(() => mockedComponent.state('count')); }; const firstValue = await first(); const secondValue = await second(); assert(firstValue === 0 && secondValue === -1, 'message: Clicking the decrement button should decrement the count by 1.'); }; ", "async () => { const waitForIt = (fn) => new Promise((resolve, reject) => setTimeout(() => resolve(fn()), 250)); const mockedComponent = Enzyme.mount(React.createElement(Counter)); const init = () => { mockedComponent.setState({ count: 0 }); return waitForIt(() => mockedComponent.state('count')); }; const increment = () => { mockedComponent.find('.inc').simulate('click'); mockedComponent.find('.inc').simulate('click'); return waitForIt(() => mockedComponent.state('count')); }; const decrement = () => { mockedComponent.find('.dec').simulate('click'); return waitForIt(() => mockedComponent.state('count')); }; const reset = () => { mockedComponent.find('.reset').simulate('click'); return waitForIt(() => mockedComponent.state('count')); }; const firstValue = await init(); const secondValue = await increment(); const thirdValue = await decrement(); const fourthValue = await reset(); assert(firstValue === 0 && secondValue === 2 && thirdValue === 1 && fourthValue === 0, 'message: Clicking the reset button should reset the count to 0.'); }; "