mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
@@ -12,17 +12,18 @@ next: clone-with-props.html
|
||||
### Simulate
|
||||
|
||||
```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:
|
||||
|
||||
```javascript
|
||||
React.addons.TestUtils.Simulate.click(myComponent);
|
||||
React.addons.TestUtils.Simulate.change(myComponent);
|
||||
React.addons.TestUtils.Simulate.keyDown(myComponent, {key: "Enter"});
|
||||
var node = this.refs.input.getDOMNode();
|
||||
React.addons.TestUtils.Simulate.click(node);
|
||||
React.addons.TestUtils.Simulate.change(node);
|
||||
React.addons.TestUtils.Simulate.keyDown(node, {key: "Enter"});
|
||||
```
|
||||
|
||||
`Simulate` has a method for every event that React understands.
|
||||
|
||||
Reference in New Issue
Block a user