-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Docs]
mount
: add missing getElement
/getElements
docs
Fixes #2574
- Loading branch information
Showing
3 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# `.getElement() => ReactElement` | ||
|
||
Returns the wrapped ReactElement. | ||
|
||
If the current wrapper is wrapping the root component, returns the root component's latest render output. | ||
|
||
|
||
#### Returns | ||
|
||
`ReactElement`: The retrieved ReactElement. | ||
|
||
|
||
|
||
#### Examples | ||
|
||
```jsx | ||
const element = ( | ||
<div> | ||
<span /> | ||
<span /> | ||
</div> | ||
); | ||
|
||
function MyComponent() { | ||
return element; | ||
} | ||
|
||
const wrapper = mount(<MyComponent />); | ||
expect(wrapper.getElement()).to.equal(element); | ||
``` | ||
|
||
|
||
|
||
#### Related Methods | ||
|
||
- [`.getElements() => Array<ReactElement>`](getElements.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# `.getElements() => Array<ReactElement>` | ||
|
||
Returns the wrapped ReactElements | ||
|
||
If the current wrapper is wrapping the root component, returns the root component's latest render output wrapped in an array. | ||
|
||
|
||
#### Returns | ||
|
||
`Array<ReactElement>`: The retrieved ReactElements. | ||
|
||
|
||
|
||
#### Examples | ||
|
||
```jsx | ||
const one = <span />; | ||
const two = <span />; | ||
|
||
function Test() { | ||
return ( | ||
<div> | ||
{one} | ||
{two} | ||
</div> | ||
); | ||
} | ||
|
||
const wrapper = mount(<Test />); | ||
expect(wrapper.find('span').getElements()).to.deep.equal([one, two]); | ||
``` | ||
|
||
|
||
|
||
#### Related Methods | ||
|
||
- [`.getElement() => ReactElement`](getElement.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters