-
-
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.
Update Docs for .getNode and .getNodes #743
- Loading branch information
1 parent
010e9f0
commit d42527e
Showing
6 changed files
with
157 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,34 @@ | ||
# `.getNode() => ReactElement` | ||
|
||
Returns the wrapper's underlying node. | ||
|
||
|
||
#### Returns | ||
|
||
`ReactElement`: The retrieved node. | ||
|
||
|
||
|
||
#### Examples | ||
|
||
```jsx | ||
class Test extends React.Component { | ||
render() { | ||
return ( | ||
<div> | ||
<span /> | ||
<span /> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
const wrapper = mount(<Test />); | ||
expect(wrapper.getNode()).to.be.an.instanceof(Test); | ||
``` | ||
|
||
|
||
|
||
#### Related Methods | ||
|
||
- [`.getNodes() => Array<ReactElement>`](getNodes.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,34 @@ | ||
# `.getNodes() => Array<ReactElement>` | ||
|
||
Returns the wrapper's underlying nodes. | ||
|
||
|
||
#### Returns | ||
|
||
`Array<ReactElement>`: The retrieved nodes. | ||
|
||
|
||
|
||
#### Examples | ||
|
||
```jsx | ||
class Test extends React.Component { | ||
render() { | ||
return ( | ||
<div> | ||
<span /> | ||
<span /> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
const wrapper = mount(<Test />); | ||
expect(wrapper.find('span').getNodes()).to.have.lengthOf(2); | ||
``` | ||
|
||
|
||
|
||
#### Related Methods | ||
|
||
- [`.getNode() => ReactElement`](getNode.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,38 @@ | ||
# `.getNode() => ReactElement` | ||
|
||
Returns the wrapper's underlying node. | ||
|
||
If the current wrapper is wrapping the root component, returns the root component's latest render output. | ||
|
||
|
||
#### Returns | ||
|
||
`ReactElement`: The retrieved node. | ||
|
||
|
||
|
||
#### Examples | ||
|
||
```jsx | ||
const element = ( | ||
<div> | ||
<span /> | ||
<span /> | ||
</div> | ||
); | ||
|
||
class MyComponent extends React.Component { | ||
render() { | ||
return element; | ||
} | ||
} | ||
|
||
const wrapper = shallow(<MyComponent />); | ||
expect(wrapper.getNode()).to.equal(element); | ||
``` | ||
|
||
|
||
|
||
#### Related Methods | ||
|
||
- [`.getNodes() => Array<ReactElement>`](getNodes.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,39 @@ | ||
# `.getNodes() => Array<ReactElement>` | ||
|
||
Returns the wrapper's underlying nodes. | ||
|
||
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 nodes. | ||
|
||
|
||
|
||
#### Examples | ||
|
||
```jsx | ||
const one = <span />; | ||
const two = <span />; | ||
|
||
class Test extends React.Component { | ||
render() { | ||
return ( | ||
<div> | ||
{ one } | ||
{ two } | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
const wrapper = shallow(<Test />); | ||
expect(wrapper.find('span').getNodes()).to.deep.equal([one, two]); | ||
``` | ||
|
||
|
||
|
||
#### Related Methods | ||
|
||
- [`.getNode() => ReactElement`](getNode.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
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