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 <nhcarrigan@gmail.com>

Co-authored-by: Parth Parth <34807532+thecodingaviator@users.noreply.github.com>
Co-authored-by: Nicholas Carrigan <nhcarrigan@gmail.com>
This commit is contained in:
Aviel212
2020-08-25 18:41:35 +03:00
committed by GitHub
parent fccc436e23
commit fb77d48d13

View File

@ -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: <code>MyComponent</code> should render to the DOM.
testString: assert(document.getElementById('challenge-node').childNodes.length === 1);
- text: <code>MyComponent</code> should have a constructor calling <code>super</code> with <code>props</code>.
testString: assert(MyComponent.toString().includes('MyComponent(props)') && MyComponent.toString().includes('_super.call(this, props)'));
```
</section>