@@ -3,7 +3,7 @@ import ReactDOM from 'react-dom';
33import TestUtils from 'react-addons-test-utils' ;
44import * as most from 'most' ;
55
6- import Most , { connect } from '../../dist/react-most' ;
6+ import Most , { connect , REACT_MOST_ENGINE } from '../../dist/react-most' ;
77import { stateStreamOf , stateHistoryOf ,
88 intentStreamOf , intentHistoryOf ,
99 run , dispatch ,
@@ -17,8 +17,8 @@ const CounterView = React.createClass({
1717 < span className = "count" > { this . props . count } </ span >
1818 < span className = "wrapperProps" > { this . props . wrapperProps } </ span >
1919 < span className = "overwritedProps" > { this . props . overwritedProps } </ span >
20- < span className = "backward" onClick = { this . props . history . backward } > -</ span >
21- < span className = "forward" onClick = { this . props . history . forward } > +</ span >
20+ < span className = "backward" onClick = { this . props . traveler . backward . bind ( this . props . traveler ) } > -</ span >
21+ < span className = "forward" onClick = { this . props . traveler . forward . bind ( this . props . traveler ) } > +</ span >
2222 </ div >
2323 )
2424 }
@@ -28,9 +28,10 @@ CounterView.defaultProps = {count: 0, overwritedProps: 'inner'}
2828
2929const counterWrapper = connect ( intent$ => {
3030 return {
31- updates : intent$ . map ( intent => {
31+ update$ : intent$ . map ( intent => {
3232 switch ( intent . type ) {
33- case 'inc' : return state => ( { count :state . count + 1 } )
33+ case 'inc' :
34+ return state => ( { count :state . count + 1 } )
3435 case 'dec' :
3536 intent$ . send ( { type :'dec triggered' } )
3637 return state => ( { count :state . count - 1 } )
@@ -56,7 +57,7 @@ const Counter = counterWrapper(CounterView)
5657
5758describe ( 'react-most' , ( ) => {
5859 describe ( 'actions' , ( ) => {
59- it . only ( 'add intent to intent$ and go through sink$' , ( ) => {
60+ it ( 'add intent to intent$ and go through sink$' , ( ) => {
6061 let counterWrapper = TestUtils . renderIntoDocument (
6162 < Most engine = { Engine } >
6263 < Counter history = { true } />
@@ -66,7 +67,6 @@ describe('react-most', () => {
6667 counter . actions . inc ( )
6768 counter . actions . inc ( )
6869 counter . actions . inc ( )
69- console . log ( stateHistoryOf ( counter ) ) ;
7070 expect ( stateHistoryOf ( counter ) [ 2 ] . count ) . toBe ( 3 )
7171 } )
7272
@@ -182,7 +182,7 @@ describe('react-most', () => {
182182 describe ( 'composable' , ( ) => {
183183 const counterWrapper2 = connect ( intent$ => {
184184 return {
185- sink $ : intent$ . map ( intent => {
185+ update $ : intent$ . map ( intent => {
186186 switch ( intent . type ) {
187187 case 'inc2' :
188188 return state => ( { count :state . count + 2 } )
@@ -192,31 +192,40 @@ describe('react-most', () => {
192192 return state => state
193193 }
194194 } ) ,
195- inc2 : ( ) => ( { type :'inc2' } ) ,
196- dec2 : ( ) => ( { type :'dec2' } ) ,
195+ actions : {
196+ inc2 : ( ) => ( { type :'inc2' } ) ,
197+ dec2 : ( ) => ( { type :'dec2' } ) ,
198+ }
197199 }
198200 } )
199201 let counterWrapper21 = compose ( counterWrapper2 ) ( counterWrapper )
200202 const Counter2 = counterWrapper21 ( CounterView )
201- it ( 'counter add inc2, dec2' , ( ) => {
202- let counterWrapper = TestUtils . renderIntoDocument (
203+ xit ( 'counter add inc2, dec2' , ( done ) => {
204+ let counterWrapperr = TestUtils . renderIntoDocument (
203205 < Most engine = { Engine } >
204206 < Counter2 history = { true } />
205207 </ Most >
206208 )
207- let counterView = TestUtils . findRenderedComponentWithType ( counterWrapper , CounterView )
208- let counter = TestUtils . findRenderedComponentWithType ( counterWrapper , Counter2 )
209+ let counterView = TestUtils . findRenderedComponentWithType ( counterWrapperr , CounterView )
210+ /* let counter = TestUtils.findRenderedComponentWithType(counterWrapperr, Counter)*/
211+ let counter2 = TestUtils . findRenderedComponentWithType ( counterWrapperr , Counter2 )
209212 counterView . props . actions . inc ( )
210- counterView . props . actions . inc2 ( )
211- counterView . props . actions . dec ( )
212- expect ( stateHistoryOf ( counter ) [ 2 ] . count ) . toBe ( 2 )
213+ console . log ( counterView . props . actions . inc . toString ( ) )
214+ /* counterView.props.actions.inc2()*/
215+ /* counterView.props.actions.dec()*/
216+
217+ expect ( stateHistoryOf ( counter2 ) ) . toBe ( 2 )
218+ /* expect(stateHistoryOf(counter
219+ )).toBe(2)*/
220+ return intentStreamOf ( counter2 ) . take ( 1 ) . observe ( x => console . log ( x ) ) . then ( x => expect ( false ) . toBe ( true ) ) . then ( done )
221+
213222 } )
214223 } )
215224
216225 describe ( 'convension default to `action` field in sinks' , ( ) => {
217226 const Counter = connect ( intent$ => {
218227 return {
219- sink $ : intent$ . map ( intent => {
228+ update $ : intent$ . map ( intent => {
220229 switch ( intent . type ) {
221230 case 'inc3' :
222231 return state => ( { count :state . count + 3 } )
@@ -246,7 +255,7 @@ describe('react-most', () => {
246255 describe ( 'ERROR' , ( ) => {
247256 const Counter = connect ( intent$ => {
248257 return {
249- sink $ : intent$ . map ( intent => {
258+ update $ : intent$ . map ( intent => {
250259 switch ( intent . type ) {
251260 case 'exception' :
252261 throw 'exception in reducer'
@@ -298,15 +307,14 @@ describe('react-most', () => {
298307 return _ => _
299308 } )
300309 return {
301- incForever$,
302- sink$ : intent$ . map ( intent => {
310+ update$ : intent$ . map ( intent => {
303311 switch ( intent . type ) {
304312 case 'inc' :
305313 return state => ( { count :state . count + 1 } )
306314 default :
307315 return state => state
308316 }
309- } )
317+ } ) . merge ( incForever$ )
310318 }
311319 } ) ( CounterView )
312320
0 commit comments