Add test for system injection with mapStateToProps containers
This commit is contained in:
@@ -472,17 +472,18 @@ describe("bound system", function(){
|
|||||||
class ContainerComponent extends PureComponent {
|
class ContainerComponent extends PureComponent {
|
||||||
mapStateToProps(nextState, props) {
|
mapStateToProps(nextState, props) {
|
||||||
return {
|
return {
|
||||||
"abc": "This came from mapStateToProps"
|
"fromMapState": "This came from mapStateToProps"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
"abc" : ""
|
"fromMapState" : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const { exampleSelectors, fromMapState, fromOwnProps } = this.props
|
||||||
return (
|
return (
|
||||||
<div>{ this.props.abc }</div>
|
<div>{ fromMapState } {exampleSelectors.foo()} {fromOwnProps}</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -493,6 +494,15 @@ describe("bound system", function(){
|
|||||||
components: {
|
components: {
|
||||||
ContainerComponent
|
ContainerComponent
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
statePlugins: {
|
||||||
|
example: {
|
||||||
|
selectors: {
|
||||||
|
foo() { return "and this came from the system" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
@@ -501,12 +511,12 @@ describe("bound system", function(){
|
|||||||
var Component = system.getSystem().getComponent("ContainerComponent", true)
|
var Component = system.getSystem().getComponent("ContainerComponent", true)
|
||||||
const renderedComponent = render(
|
const renderedComponent = render(
|
||||||
<Provider store={system.getStore()}>
|
<Provider store={system.getStore()}>
|
||||||
<Component />
|
<Component fromOwnProps="and this came from my own props" />
|
||||||
</Provider>
|
</Provider>
|
||||||
)
|
)
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
expect(renderedComponent.text()).toEqual("This came from mapStateToProps")
|
expect(renderedComponent.text()).toEqual("This came from mapStateToProps and this came from the system and this came from my own props")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user