Browse Source

Update test-utils to use refs correctly (#215)

* Update test-utils to use refs correctly

Update test-utils according to the new way of using refs: https://reactjs.org/docs/refs-and-the-dom.html

* Tweak
main
Daniela Borges Matos de Carvalho 7 years ago
committed by Dan Abramov
parent
commit
dfdddfd7cd
  1. 8
      content/docs/addons-test-utils.md

8
content/docs/addons-test-utils.md

@ -66,16 +66,16 @@ Simulate an event dispatch on a DOM node with optional `eventData` event data.
**Clicking an element**
```javascript
// <button ref="button">...</button>
const node = this.refs.button;
// <button ref={(node) => this.button = node}>...</button>
const node = this.button;
ReactTestUtils.Simulate.click(node);
```
**Changing the value of an input field and then pressing ENTER.**
```javascript
// <input ref="input" />
const node = this.refs.input;
// <input ref={(node) => this.textInput = node} />
const node = this.textInput;
node.value = 'giraffe';
ReactTestUtils.Simulate.change(node);
ReactTestUtils.Simulate.keyDown(node, {key: "Enter", keyCode: 13, which: 13});

Loading…
Cancel
Save