Skip to content

Commit

Permalink
[Docs] shallow/mount: SyntheticEvent and event properties note
Browse files Browse the repository at this point in the history
Fixes #1748.
  • Loading branch information
alejo4373 authored and ljharb committed Aug 16, 2018
1 parent 73ddee4 commit baaa2b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/api/ReactWrapper/simulate.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ expect(wrapper.find('.clicks-0').length).to.equal(1);
wrapper.find('a').simulate('click');
expect(wrapper.find('.clicks-1').length).to.equal(1);
```
#### Common Gotchas

- As noted in the function signature above passing a mock event is optional. It is worth noting that `ReactWrapper` will pass a `SyntheticEvent` object to the event handler in your code. Keep in mind that if the code you are testing uses properties that are not included in the `SyntheticEvent`, for instance `event.target.value`, you will need to provide a mock event like so `.simulate("change", { target: { value: "foo" }})` for it to work.

1 change: 1 addition & 0 deletions docs/api/ShallowWrapper/simulate.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ the event handler set.
- Even though the name would imply this simulates an actual event, `.simulate()` will in fact
target the component's prop based on the event you give it. For example, `.simulate('click')` will
actually get the `onClick` prop and call it.
- As noted in the function signature above passing a mock event is optional. Keep in mind that if the code you are testing uses the event for something like, calling `event.preventDefault()` or accessing any of its properties you must provide a mock event object with the properties your code requires.

0 comments on commit baaa2b5

Please sign in to comment.