File tree Expand file tree Collapse file tree 3 files changed +20
-4
lines changed
Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import ReactDOM from 'react-dom';
33import TestUtils from 'react-addons-test-utils' ;
44import * as most from 'most' ;
55import { compose } from 'ramda' ;
6- import Most , { connect } from 'react-most' ;
6+ import Most , { connect } from '../ react-most' ;
77import { stateStreamOf , stateHistoryOf ,
88 intentStreamOf , intentHistoryOf ,
99 run , dispatch ,
@@ -65,6 +65,22 @@ describe('react-most', () => {
6565 expect ( stateHistoryOf ( counter ) [ 2 ] . count ) . toBe ( 3 )
6666 } )
6767
68+ it ( 'async action' , ( ) => {
69+ let counterWrapper = TestUtils . renderIntoDocument (
70+ < Most engine = { Engine } >
71+ < Counter history = { true } />
72+ </ Most >
73+ )
74+ let counter = TestUtils . findRenderedComponentWithType ( counterWrapper , Counter )
75+ counter . actions . inc ( ) ;
76+ counter . actions . fromEvent ( { type :'inc' } ) ;
77+ return counter . actions . fromPromise ( Promise . resolve ( { type :'inc' } ) )
78+ . then ( ( ) => {
79+ expect ( stateHistoryOf ( counter ) [ 2 ] . count ) . toBe ( 3 )
80+ } )
81+
82+ } )
83+
6884 it ( 'sink can also generate intent' , ( ) => {
6985 let counterWrapper = TestUtils . renderIntoDocument (
7086 < Most engine = { Engine } >
Original file line number Diff line number Diff line change @@ -123,10 +123,10 @@ function actionsAndSinks(sinks, self){
123123 let _sinks = [ ] ;
124124 let _actions = {
125125 fromEvent ( e , f = x => x ) {
126- self . context [ INTENT_STREAM ] . send ( f ( e ) ) ;
126+ return self . context [ INTENT_STREAM ] . send ( f ( e ) ) ;
127127 } ,
128128 fromPromise ( p ) {
129- p . then ( x => self . context [ INTENT_STREAM ] . send ( x ) ) ;
129+ return p . then ( x => self . context [ INTENT_STREAM ] . send ( x ) ) ;
130130 }
131131 } ;
132132 for ( let name in sinks ) {
Original file line number Diff line number Diff line change 2121 "build" : " babel lib -d ./ --ignore '__tests__' && npm run license" ,
2222 "prebrowser" : " npm run build" ,
2323 "browser" : " browserify -r react -r most -r most-subject -o dist/vendor.js && browserify -s Most -x react -x most -x most-subject react-most.js -o dist/react-most.js" ,
24- "test" : " jest" ,
24+ "test" : " jest --coverage " ,
2525 "prepublish" : " npm run build" ,
2626 "testWDebugger" : " node --harmony $(which bugger) ./node_modules/jest-cli/bin/jest.js --runInBand"
2727 },
You can’t perform that action at this time.
0 commit comments