From e7bc4bd0141fc282d167f7d854da5798f74990f6 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Mon, 18 Mar 2019 17:56:46 +0100 Subject: [PATCH] fix: Allow trailing commas to be used in challenge (#35585) * fix: Allow trailing commas to be used in challenge * fix: use regex to simplify challenge tests * Update curriculum/challenges/english/03-front-end-libraries/react/review-using-props-with-stateless-functional-components.english.md Co-Authored-By: ojeytonwilliams --- ...ops-with-stateless-functional-components.english.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/curriculum/challenges/english/03-front-end-libraries/react/review-using-props-with-stateless-functional-components.english.md b/curriculum/challenges/english/03-front-end-libraries/react/review-using-props-with-stateless-functional-components.english.md index 4426221a12..4592d3ba85 100644 --- a/curriculum/challenges/english/03-front-end-libraries/react/review-using-props-with-stateless-functional-components.english.md +++ b/curriculum/challenges/english/03-front-end-libraries/react/review-using-props-with-stateless-functional-components.english.md @@ -23,15 +23,15 @@ The code editor has a CampSite component that renders a Campe ```yml tests: - text: The CampSite component should render. - testString: assert((function() { const mockedComponent = Enzyme.mount(React.createElement(CampSite)); return mockedComponent.find('CampSite').length === 1; })(), 'The CampSite component should render.'); + testString: assert((function() { const mockedComponent = Enzyme.mount(React.createElement(CampSite)); return mockedComponent.find('CampSite').length === 1; })()); - text: The Camper component should render. - testString: assert((function() { const mockedComponent = Enzyme.mount(React.createElement(CampSite)); return mockedComponent.find('Camper').length === 1; })(), 'The Camper component should render.'); + testString: assert((function() { const mockedComponent = Enzyme.mount(React.createElement(CampSite)); return mockedComponent.find('Camper').length === 1; })()); - text: The Camper component should include default props which assign the string CamperBot to the key name. - testString: getUserInput => assert((function() { const noWhiteSpace = getUserInput('index').replace(/\s/g, ''); const verify1 = 'Camper.defaultProps={name:\'CamperBot\'}'; const verify2 = 'Camper.defaultProps={name:"CamperBot"}'; return (noWhiteSpace.includes(verify1) || noWhiteSpace.includes(verify2)); })(), 'The Camper component should include default props which assign the string CamperBot to the key name.'); + testString: assert(/Camper.defaultProps={name:(['"`])CamperBot\1,?}/.test(code.replace(/\s/g, ''))); - text: The Camper component should include prop types which require the name prop to be of type string. - testString: getUserInput => assert((function() { const mockedComponent = Enzyme.mount(React.createElement(CampSite)); const noWhiteSpace = getUserInput('index').replace(/\s/g, ''); const verifyDefaultProps = 'Camper.propTypes={name:PropTypes.string.isRequired}'; return noWhiteSpace.includes(verifyDefaultProps); })(), 'The Camper component should include prop types which require the name prop to be of type string.'); + testString: assert(/Camper.propTypes={name:PropTypes.string.isRequired,?}/.test(code.replace(/\s/g, ''))); - text: The Camper component should contain a p element with only the text from the name prop. - testString: assert((function() { const mockedComponent = Enzyme.mount(React.createElement(CampSite)); return mockedComponent.find('p').text() === mockedComponent.find('Camper').props().name; })(), 'The Camper component should contain a p element with only the text from the name prop.'); + testString: assert((function() { const mockedComponent = Enzyme.mount(React.createElement(CampSite)); return mockedComponent.find('p').text() === mockedComponent.find('Camper').props().name; })()); ```