@@ -25,6 +25,14 @@ describe('<Reductor />', function() {
2525 } ) ) ;
2626 }
2727
28+ class BazConnector extends Connector {
29+ static $connection = TestConnection ;
30+ static $state = { } ;
31+ static $reducer = BazConnector . reduce ( 'common.baz' , ( state ) => ( {
32+ $set : ( key , value ) => ( { ...state , [ key ] : value } )
33+ } ) ) ;
34+ }
35+
2836 class MockRoute extends Component {
2937 static propTypes = {
3038 komponent : PropTypes . func
@@ -38,7 +46,7 @@ describe('<Reductor />', function() {
3846
3947 beforeEach ( function ( ) {
4048 this . wrapper = mount (
41- < Reductor createStore = { createStore } connectorProp = "komponent" >
49+ < Reductor createStore = { createStore } connectors = { [ BazConnector ] } connectorProp = "komponent" >
4250 < MockRoute komponent = { FooConnector } />
4351 < div className = "deeply-nested-connector" >
4452 < MockRoute komponent = { BarConnector } />
@@ -53,12 +61,16 @@ describe('<Reductor />', function() {
5361 expect ( this . wrapper . contains ( < div > some content</ div > ) ) . toBe ( true ) ;
5462 } ) ;
5563
56- it ( 'generates a reducer function based on child connectors and creates a store based on it' , function ( ) {
57- expect ( this . store . getState ( ) ) . toEqual ( { common : { foo : { } , bar : { } } } ) ;
64+ it ( 'generates a reducer function based on props and child connectors and creates a store based on it' , function ( ) {
65+ expect ( this . store . getState ( ) ) . toEqual ( { common : { foo : { } , bar : { } , baz : { } } } ) ;
5866
5967 this . store . dispatch ( { type : 'common.foo/$set' , args : [ 'text' , 'A Text' ] } ) ;
6068
61- expect ( this . store . getState ( ) ) . toEqual ( { common : { foo : { text : 'A Text' } , bar : { } } } ) ;
69+ expect ( this . store . getState ( ) ) . toEqual ( { common : { foo : { text : 'A Text' } , bar : { } , baz : { } } } ) ;
6270 expect ( this . wrapper . contains ( < div > A Text</ div > ) ) . toBe ( true ) ;
71+
72+ this . store . dispatch ( { type : 'common.baz/$set' , args : [ 'text' , 'Not mounted' ] } ) ;
73+
74+ expect ( this . store . getState ( ) ) . toEqual ( { common : { foo : { text : 'A Text' } , bar : { } , baz : { text : 'Not mounted' } } } ) ;
6375 } ) ;
6476} ) ;
0 commit comments