-
-
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.
use getter for .node and .nodes in ShallowWrapper to ensure render ou…
…tput is always fresh. removes need for .update
- Loading branch information
Showing
5 changed files
with
58 additions
and
51 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 |
---|---|---|
@@ -1,33 +0,0 @@ | ||
# `.update() => Self` | ||
|
||
Forces a re-render. Useful to run before checking the render output if something external | ||
may be updating the state of the component somewhere. | ||
|
||
NOTE: can only be called on a wrapper instance that is also the root instance. | ||
|
||
|
||
#### Returns | ||
|
||
`ShallowWrapper`: Returns itself. | ||
|
||
|
||
|
||
#### Example | ||
|
||
```jsx | ||
class ImpureRender extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.count = 0; | ||
} | ||
render() { | ||
return <div>{this.count++}</div> | ||
} | ||
} | ||
``` | ||
```jsx | ||
const wrapper = shallow(<ImpureRender />); | ||
expect(wrapper.text()).to.equal("0"); | ||
wrapper.update(); | ||
expect(wrapper.text()).to.equal("1"); | ||
``` | ||
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