@@ -23,17 +23,38 @@ const testStore = {
2323 }
2424}
2525
26+ const testStore2 = {
27+ namespace : 'boop' ,
28+ state : {
29+ header : 'beep'
30+ } ,
31+ reducers : {
32+ update : function ( state , data ) {
33+ return { header : data }
34+ }
35+ }
36+ }
37+
2638const TestComponent = React . createClass ( {
2739 change : function ( evt ) {
2840 evt . preventDefault ( )
29- this . props . send ( 'update' , 'foobar' )
41+ this . props . send ( 'foo: update' , 'foobar' )
3042 } ,
3143 render : function ( ) {
3244 const props = {
33- onClick : ( evt ) => this . props . send ( 'update' , 'foobar' ) ,
34- onBlur : ( evt ) => this . props . send ( 'makeError' )
45+ onClick : ( evt ) => this . props . send ( 'foo: update' , 'foobar' ) ,
46+ onBlur : ( evt ) => this . props . send ( 'foo: makeError' )
3547 }
36- return React . createElement ( 'h1' , props , `${ this . props . err || this . props . model . header } ` )
48+ return React . createElement ( 'h1' , props , `${ this . props . err || this . props . data . foo . header } ` )
49+ }
50+ } )
51+
52+ const TestComponent2 = React . createClass ( {
53+ render : function ( ) {
54+ const props = {
55+ onClick : ( evt ) => this . props . send ( 'boop:update' , 'plorb' )
56+ }
57+ return React . createElement ( 'h1' , props , `${ this . props . data . boop . header } ${ this . props . data . foo . header } ` )
3758 }
3859} )
3960
@@ -61,25 +82,15 @@ tape('basic', (t) => {
6182 } , 5 )
6283} )
6384
64- tape ( 'no namespace' , ( t ) => {
65- const store = {
66- state : {
67- header : 'beep'
68- } ,
69- reducers : {
70- update : function ( state , data ) {
71- return { header : data }
72- }
73- }
74- }
75- const Test = bearact ( TestComponent , store )
85+ tape ( 'multimodel' , ( t ) => {
86+ const Test = bearact ( TestComponent2 , [ testStore , testStore2 ] )
7687 const el = React . createElement ( Test , { } , null )
7788 const wrapper = mount ( el )
7889 const h1 = wrapper . find ( 'h1' )
79- t . equal ( h1 . text ( ) , store . state . header )
90+ t . equal ( h1 . text ( ) , ` ${ testStore2 . state . header } ${ testStore . state . header } ` )
8091 h1 . simulate ( 'click' )
8192 setTimeout ( ( ) => {
82- t . equal ( wrapper . find ( 'h1' ) . text ( ) , 'foobar ' )
93+ t . equal ( wrapper . find ( 'h1' ) . text ( ) , 'plorb test ' )
8394 t . end ( )
8495 } , 5 )
8596} )
0 commit comments