-
-
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.
[New]
mount
/shallow
: add getWrappingComponent
- Loading branch information
1 parent
26f5492
commit cc3db79
Showing
10 changed files
with
843 additions
and
4 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,45 @@ | ||
# `.getWrappingComponent() => ReactWrapper` | ||
|
||
If a `wrappingComponent` was passed in `options`, this methods returns a `ReactWrapper` around the rendered `wrappingComponent`. This `ReactWrapper` can be used to update the `wrappingComponent`'s props, state, etc. | ||
|
||
|
||
#### Returns | ||
|
||
`ReactWrapper`: A `ReactWrapper` around the rendered `wrappingComponent` | ||
|
||
|
||
|
||
#### Examples | ||
|
||
```jsx | ||
import { Provider } from 'react-redux'; | ||
import { Router } from 'react-router'; | ||
import store from './my/app/store'; | ||
import mockStore from './my/app/mockStore'; | ||
|
||
function MyProvider(props) { | ||
const { children, customStore } = props; | ||
|
||
return ( | ||
<Provider store={customStore || store}> | ||
<Router> | ||
{children} | ||
</Router> | ||
</Provider> | ||
); | ||
} | ||
MyProvider.propTypes = { | ||
children: PropTypes.node, | ||
customStore: PropTypes.shape({}), | ||
}; | ||
MyProvider.defaultProps = { | ||
children: null, | ||
customStore: null, | ||
}; | ||
|
||
const wrapper = mount(<MyComponent />, { | ||
wrappingComponent: MyProvider, | ||
}); | ||
const provider = wrapper.getWrappingComponent(); | ||
provider.setProps({ customStore: mockStore }); | ||
``` |
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,45 @@ | ||
# `.getWrappingComponent() => ShallowWrapper` | ||
|
||
If a `wrappingComponent` was passed in `options`, this methods returns a `ShallowWrapper` around the rendered `wrappingComponent`. This `ShallowWrapper` can be used to update the `wrappingComponent`'s props, state, etc. | ||
|
||
|
||
#### Returns | ||
|
||
`ShallowWrapper`: A `ShallowWrapper` around the rendered `wrappingComponent` | ||
|
||
|
||
|
||
#### Examples | ||
|
||
```jsx | ||
import { Provider } from 'react-redux'; | ||
import { Router } from 'react-router'; | ||
import store from './my/app/store'; | ||
import mockStore from './my/app/mockStore'; | ||
|
||
function MyProvider(props) { | ||
const { children, customStore } = props; | ||
|
||
return ( | ||
<Provider store={customStore || store}> | ||
<Router> | ||
{children} | ||
</Router> | ||
</Provider> | ||
); | ||
} | ||
MyProvider.propTypes = { | ||
children: PropTypes.node, | ||
customStore: PropTypes.shape({}), | ||
}; | ||
MyProvider.defaultProps = { | ||
children: null, | ||
customStore: null, | ||
}; | ||
|
||
const wrapper = shallow(<MyComponent />, { | ||
wrappingComponent: MyProvider, | ||
}); | ||
const provider = wrapper.getWrappingComponent(); | ||
provider.setProps({ customStore: mockStore }); | ||
``` |
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
Oops, something went wrong.
cc3db79
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry but I'm not sure: enzyme-adapter-react-16@1.12.0 is released but not a new version of enzyme (still in 3.9.0) so it doesn't work yet ?
cc3db79
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's correct.