Browse Source

Update Simulate docs to reflect reality

cf. #1532, #1445.
main
Ben Alpert 11 years ago
parent
commit
4c73aad3cc
  1. 11
      docs/09.4-test-utils.md

11
docs/09.4-test-utils.md

@ -12,17 +12,18 @@ next: clone-with-props.html
### Simulate ### Simulate
```javascript ```javascript
Simulate.{eventName}({ReactComponent|DOMElement} element, object eventData) Simulate.{eventName}(DOMElement element, object eventData)
``` ```
Simulate an event dispatch on a React component instance or browser DOM node with optional `eventData` event data. **This is possibly the single most useful utility in `ReactTestUtils`.** Simulate an event dispatch on a DOM node with optional `eventData` event data. **This is possibly the single most useful utility in `ReactTestUtils`.**
Example usage: Example usage:
```javascript ```javascript
React.addons.TestUtils.Simulate.click(myComponent); var node = this.refs.input.getDOMNode();
React.addons.TestUtils.Simulate.change(myComponent); React.addons.TestUtils.Simulate.click(node);
React.addons.TestUtils.Simulate.keyDown(myComponent, {key: "Enter"}); React.addons.TestUtils.Simulate.change(node);
React.addons.TestUtils.Simulate.keyDown(node, {key: "Enter"});
``` ```
`Simulate` has a method for every event that React understands. `Simulate` has a method for every event that React understands.

Loading…
Cancel
Save