-
-
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.
Merge pull request #71 from nfpiche/add-html-to-render
Add method, tests, and docs for html method in ReactWrapper
- Loading branch information
Showing
5 changed files
with
107 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
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,54 @@ | ||
# `.html() => String` | ||
|
||
Returns a string of the rendered HTML markup of the current render tree. | ||
|
||
Note: can only be called on a wrapper of a single node. | ||
|
||
|
||
#### Returns | ||
|
||
`String`: The resulting HTML string | ||
|
||
|
||
|
||
#### Examples | ||
|
||
```jsx | ||
class Foo extends React.Component { | ||
render() { | ||
return (<div className="in-foo" />); | ||
} | ||
} | ||
``` | ||
|
||
```jsx | ||
class Bar extends React.Component { | ||
render() { | ||
return ( | ||
<div className="in-bar"> | ||
<Foo /> | ||
</div> | ||
); | ||
} | ||
} | ||
``` | ||
|
||
```jsx | ||
const wrapper = mount(<Bar />); | ||
expect(wrapper.html()).to.equal( | ||
`<div class="in-bar"><div class="in-foo"></div></div>` | ||
); | ||
expect(wrapper.find(Foo).html()).to.equal( | ||
`<div class="in-foo"></div>` | ||
); | ||
``` | ||
|
||
```jsx | ||
const wrapper = mount(<div><b>important</b></div>); | ||
expect(wrapper.html()).to.equal('<div><b>important</b></div>'); | ||
``` | ||
|
||
|
||
#### Related Methods | ||
|
||
[`.text() => String`](text.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
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