@samitouri / QOS-React-2 / commits / 807c62851c

Make definitions more readable & optional params more obvious

Andreas Savvides committed Aug 27, 2015 at 16:32 UTC 807c62851c7451a8db333cb1c340f91e6e48796d
1 file changed +57 -16
docs/docs/10.4-test-utils.md
+57 -16
@@ -11,7 +11,10 @@ next: clone-with-props.html
11 ### Simulate
12
13 ```javascript
14 -Simulate.{eventName}(DOMElement element, object eventData)
14 +Simulate.{eventName}(
15 + DOMElement element,
16 + [object eventData]
17 +)
18 ```
19
20 Simulate an event dispatch on a DOM node with optional `eventData` event data. **This is possibly the single most useful utility in `ReactTestUtils`.**
@@ -39,7 +42,9 @@ React.addons.TestUtils.Simulate.keyDown(node, {key: "Enter", keyCode: 13, which:
42 ### renderIntoDocument
43
44 ```javascript
42 -ReactComponent renderIntoDocument(ReactElement instance)
45 +ReactComponent renderIntoDocument(
46 + ReactElement instance
47 +)
48 ```
49
50 Render a component into a detached DOM node in the document. **This function requires a DOM.**
@@ -47,7 +52,10 @@ Render a component into a detached DOM node in the document. **This function req
52 ### mockComponent
53
54 ```javascript
50 -object mockComponent(function componentClass, string? mockTagName)
55 +object mockComponent(
56 + function componentClass,
57 + [string mockTagName]
58 +)
59 ```
60
61 Pass a mocked component module to this method to augment it with useful methods that allow it to be used as a dummy React component. Instead of rendering as usual, the component will become a simple `<div>` (or other tag if `mockTagName` is provided) containing any provided children.
@@ -55,7 +63,9 @@ Pass a mocked component module to this method to augment it with useful methods
63 ### isElement
64
65 ```javascript
58 -boolean isElement(ReactElement element)
66 +boolean isElement(
67 + ReactElement element
68 +)
69 ```
70
71 Returns `true` if `element` is any ReactElement.
@@ -63,7 +73,10 @@ Returns `true` if `element` is any ReactElement.
73 ### isElementOfType
74
75 ```javascript
66 -boolean isElementOfType(ReactElement element, function componentClass)
76 +boolean isElementOfType(
77 + ReactElement element,
78 + function componentClass
79 +)
80 ```
81
82 Returns `true` if `element` is a ReactElement whose type is of a React `componentClass`.
@@ -71,7 +84,9 @@ Returns `true` if `element` is a ReactElement whose type is of a React `componen
84 ### isDOMComponent
85
86 ```javascript
74 -boolean isDOMComponent(ReactComponent instance)
87 +boolean isDOMComponent(
88 + ReactComponent instance
89 +)
90 ```
91
92 Returns `true` if `instance` is a DOM component (such as a `<div>` or `<span>`).
@@ -79,7 +94,9 @@ Returns `true` if `instance` is a DOM component (such as a `<div>` or `<span>`).
94 ### isCompositeComponent
95
96 ```javascript
82 -boolean isCompositeComponent(ReactComponent instance)`
97 +boolean isCompositeComponent(
98 + ReactComponent instance
99 +)
100 ```
101
102 Returns `true` if `instance` is a composite component (created with `React.createClass()`).
@@ -87,7 +104,10 @@ Returns `true` if `instance` is a composite component (created with `React.creat
104 ### isCompositeComponentWithType
105
106 ```javascript
90 -boolean isCompositeComponentWithType(ReactComponent instance, function componentClass)
107 +boolean isCompositeComponentWithType(
108 + ReactComponent instance,
109 + function componentClass
110 +)
111 ```
112
113 Returns `true` if `instance` is a composite component (created with `React.createClass()`) whose type is of a React `componentClass`.
@@ -95,7 +115,10 @@ Returns `true` if `instance` is a composite component (created with `React.creat
115 ### findAllInRenderedTree
116
117 ```javascript
98 -array findAllInRenderedTree(ReactComponent tree, function test)
118 +array findAllInRenderedTree(
119 + ReactComponent tree,
120 + function test
121 +)
122 ```
123
124 Traverse all components in `tree` and accumulate all components where `test(component)` is `true`. This is not that useful on its own, but it's used as a primitive for other test utils.
@@ -103,7 +126,9 @@ Traverse all components in `tree` and accumulate all components where `test(comp
126 ### scryRenderedDOMComponentsWithClass
127
128 ```javascript
106 -array scryRenderedDOMComponentsWithClass(ReactComponent tree, string className)
129 +array scryRenderedDOMComponentsWithClass(
130 + ReactComponent tree, string className
131 +)
132 ```
133
134 Finds all instances of components in the rendered tree that are DOM components with the class name matching `className`.
@@ -111,7 +136,10 @@ Finds all instances of components in the rendered tree that are DOM components w
136 ### findRenderedDOMComponentWithClass
137
138 ```javascript
114 -ReactComponent findRenderedDOMComponentWithClass(ReactComponent tree, string className)
139 +ReactComponent findRenderedDOMComponentWithClass(
140 + ReactComponent tree,
141 + string className
142 +)
143 ```
144
145 Like `scryRenderedDOMComponentsWithClass()` but expects there to be one result, and returns that one result, or throws exception if there is any other number of matches besides one.
@@ -119,7 +147,10 @@ Like `scryRenderedDOMComponentsWithClass()` but expects there to be one result,
147 ### scryRenderedDOMComponentsWithTag
148
149 ```javascript
122 -array scryRenderedDOMComponentsWithTag(ReactComponent tree, string tagName)
150 +array scryRenderedDOMComponentsWithTag(
151 + ReactComponent tree,
152 + string tagName
153 +)
154 ```
155
156 Finds all instances of components in the rendered tree that are DOM components with the tag name matching `tagName`.
@@ -127,7 +158,10 @@ Finds all instances of components in the rendered tree that are DOM components w
158 ### findRenderedDOMComponentWithTag
159
160 ```javascript
130 -ReactComponent findRenderedDOMComponentWithTag(ReactComponent tree, string tagName)
161 +ReactComponent findRenderedDOMComponentWithTag(
162 + ReactComponent tree,
163 + string tagName
164 +)
165 ```
166
167 Like `scryRenderedDOMComponentsWithTag()` but expects there to be one result, and returns that one result, or throws exception if there is any other number of matches besides one.
@@ -135,7 +169,10 @@ Like `scryRenderedDOMComponentsWithTag()` but expects there to be one result, an
169 ### scryRenderedComponentsWithType
170
171 ```javascript
138 -array scryRenderedComponentsWithType(ReactComponent tree, function componentClass)
172 +array scryRenderedComponentsWithType(
173 + ReactComponent tree,
174 + function componentClass
175 +)
176 ```
177
178 Finds all instances of components with type equal to `componentClass`.
@@ -143,7 +180,9 @@ Finds all instances of components with type equal to `componentClass`.
180 ### findRenderedComponentWithType
181
182 ```javascript
146 -ReactComponent findRenderedComponentWithType(ReactComponent tree, function componentClass)
183 +ReactComponent findRenderedComponentWithType(
184 + ReactComponent tree, function componentClass
185 +)
186 ```
187
188 Same as `scryRenderedComponentsWithType()` but expects there to be one result and returns that one result, or throws exception if there is any other number of matches besides one.
@@ -160,7 +199,9 @@ ReactShallowRenderer createRenderer()
199 Call this in your tests to create a shallow renderer. You can think of this as a "place" to render the component you're testing, where it can respond to events and update itself.
200
201 ```javascript
163 -shallowRenderer.render(ReactElement element)
202 +shallowRenderer.render(
203 + ReactElement element
204 +)
205 ```
206
207 Similar to `React.render`.