ソースを参照

Add test for system injection with mapStateToProps containers

bubble
Kyle Shockey 6年前
コミット
7624d6b5fc
1個のファイルの変更15行の追加5行の削除
  1. +15
    -5
      test/core/system/system.js

+ 15
- 5
test/core/system/system.js ファイルの表示

@@ -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")
}) })
}) })




読み込み中…
キャンセル
保存