From fb77d48d138e743ab539e1f685b4ba5b45c1e9e5 Mon Sep 17 00:00:00 2001 From: Aviel212 Date: Tue, 25 Aug 2020 18:41:35 +0300 Subject: [PATCH] curriculum: add test in React challenge to detect constructor call (#39304) * fix: resolve #39301 Add a test to check the "MyComponent" constructor's parameters (params) and to check that the super function exists in the constructor. * docs: describe the test better * Update curriculum/challenges/english/03-front-end-libraries/react/write-a-react-component-from-scratch.english.md Co-authored-by: Nicholas Carrigan Co-authored-by: Parth Parth <34807532+thecodingaviator@users.noreply.github.com> Co-authored-by: Nicholas Carrigan --- .../react/write-a-react-component-from-scratch.english.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/curriculum/challenges/english/03-front-end-libraries/react/write-a-react-component-from-scratch.english.md b/curriculum/challenges/english/03-front-end-libraries/react/write-a-react-component-from-scratch.english.md index e19464b739..d97aa539c9 100644 --- a/curriculum/challenges/english/03-front-end-libraries/react/write-a-react-component-from-scratch.english.md +++ b/curriculum/challenges/english/03-front-end-libraries/react/write-a-react-component-from-scratch.english.md @@ -29,7 +29,8 @@ tests: testString: assert((function() { const mockedComponent = Enzyme.mount(React.createElement(MyComponent)); return mockedComponent.find('h1').text() === 'My First React Component!'; })()); - text: MyComponent should render to the DOM. testString: assert(document.getElementById('challenge-node').childNodes.length === 1); - + - text: MyComponent should have a constructor calling super with props. + testString: assert(MyComponent.toString().includes('MyComponent(props)') && MyComponent.toString().includes('_super.call(this, props)')); ```