@samitouri / QOS-React-2 / commits / 114b9c5500

Add 'Test Utils' docs back to main navigation (#9676)

* Add 'Test Utils' docs back to main navigation **why make this change?:** We accidentally removed this - still supporting the use of Test Utilities, so we should have them in the docs. **test plan:** Manually tested the website - will insert a screenshot. **issue:** https://github.com/facebook/react/issues/9651 * Move test-utils docs to reference section **what is the change?:** Moved from 'advanced guides' to 'reference' **why make this change?:** It makes more sense as a reference **test plan:** Visual inspection (flarnie may add a screenshot) **issue:** * Add back the shallow renderer docs and remove outdated docs **what is the change?:** - Remove outdated 'shallow renderer' docs on 'test utils' page, and point to the updated 'shallow renderer' docs. - Re-add a link to the updated 'shallow renderer' docs on the main navigation. **why make this change?:** This was already approved in https://github.com/facebook/react/pull/9331 which was then cherry-picked to https://github.com/facebook/react/pull/9359/commits and landed on master. I'm not sure why some of these changes didn't persist. For now just adding back the changes we need. **test plan:** Manually inspected website - will insert screenshots. **issue:** * Further improvements to 'shallow rendering' and 'test utils' docs Thanks @gaearon for the improvements! **what is the change?:** - Remove <hr/> from end of 'shallow rendering' docs - 'documents' -> 'documentation' - Move 'shallow rendering' redirection section to top of 'test utils' docs - Add intro sentence about testing to 'shallow rendering' docs **why make this change?:** Documentation helps people learn. **test plan:** Visual inspection

Flarnie Marchan committed May 26, 2017 at 07:47 UTC 114b9c5500ba21ec9e60f814148d38276c9aaa50
3 files changed +10 -33
docs/_data/nav_docs.yml
+4
@@ -67,3 +67,7 @@
67 title: DOM Elements
68 - id: events
69 title: SyntheticEvent
70 + - id: test-utils
71 + title: Test Utilities
72 + - id: shallow-renderer
73 + title: Shallow Renderer
docs/docs/addons-shallow-renderer.md
+1 -2
@@ -14,7 +14,7 @@ var ReactShallowRenderer = require('react-test-renderer/shallow'); // ES5 with n
14 ```
15 ### Shallow Rendering
16
17 -Shallow rendering lets you render a component "one level deep" and assert facts about what its render method returns, without worrying about the behavior of child components, which are not instantiated or rendered. This does not require a DOM.
17 +When writing unit tests for React, shallow rendering can be helpful. Shallow rendering lets you render a component "one level deep" and assert facts about what its render method returns, without worrying about the behavior of child components, which are not instantiated or rendered. This does not require a DOM.
18
19 - [`shallowRenderer.render()`](#shallowrenderer.render)
20 - [`shallowRenderer.getRenderOutput()`](#shallowrenderer.getrenderoutput)
@@ -57,4 +57,3 @@ Shallow testing currently has some limitations, namely not supporting refs.
57
58 We also recommend checking out Enzyme's [Shallow Rendering API](http://airbnb.io/enzyme/docs/api/shallow.html). It provides a nicer higher-level API over the same functionality.
59
60 -* * *
docs/docs/addons-test-utils.md
+5 -31
@@ -39,6 +39,11 @@ var ReactTestUtils = require('react-dom/test-utils'); // ES5 with npm
39
40 ## Reference
41
42 +## Shallow Rendering
43 +
44 +> Note:
45 +> The shallow renderer has moved to `react-test-renderer/shallow`. [Please see the updated documentation.](/react/docs/shallow-renderer.html)
46 +
47 ### `Simulate`
48
49 ```javascript
@@ -250,34 +255,3 @@ Same as [`scryRenderedComponentsWithType()`](#scryrenderedcomponentswithtype) bu
255
256 * * *
257
253 -## Shallow Rendering
254 -
255 -### `createRenderer()`
256 -
257 -```javascript
258 -createRenderer()
259 -```
260 -
261 -Call this in your tests to create a [shallow renderer](#shallow-rendering).
262 -
263 -* * *
264 -
265 -### `shallowRenderer.render()`
266 -
267 -```javascript
268 -shallowRenderer.render(
269 - element
270 -)
271 -```
272 -
273 -Similar to [`ReactDOM.render`](/react/docs/react-dom.html#render) but it doesn't require DOM and only renders a single level deep. See [Shallow Rendering](#shallow-rendering).
274 -
275 -* * *
276 -
277 -### `shallowRenderer.getRenderOutput()`
278 -
279 -```javascript
280 -shallowRenderer.getRenderOutput()
281 -```
282 -
283 -After [`shallowRenderer.render()`](#shallowrenderer.render) has been called, returns shallowly rendered output.