-
-
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 #16 from airbnb/lmr/shallow-method
Added .shallow() method to ShallowWrapper
- Loading branch information
Showing
5 changed files
with
91 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,47 @@ | ||
# `.shallow() => ShallowWrapper` | ||
|
||
Shallow renders the current node and returns a shallow wrapper around it. | ||
|
||
NOTE: can only be called on wrapper of a single node. | ||
|
||
|
||
|
||
|
||
#### Returns | ||
|
||
`ShallowWrapper`: A new wrapper that wraps the current node after it's been shallow rendered. | ||
|
||
|
||
|
||
#### Examples | ||
|
||
```jsx | ||
class Bar extends React.Component { | ||
render() { | ||
return ( | ||
<div> | ||
<div className="in-bar" /> | ||
</div> | ||
); | ||
} | ||
} | ||
``` | ||
|
||
```jsx | ||
class Foo extends React.Component { | ||
render() { | ||
return ( | ||
<div> | ||
<Bar /> | ||
</div> | ||
); | ||
} | ||
} | ||
``` | ||
|
||
```jsx | ||
const wrapper = shallow(<Foo />); | ||
expect(wrapper.find('.in-bar')).to.have.length(0); | ||
expect(wrapper.find(Bar)).to.have.length(1); | ||
expect(wrapper.find(Bar).shallow().find('.in-bar')).to.have.length(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