Skip to content

Commit 01ee932

Browse files
committed
cover fromEvent and fromPromise
1 parent de0c55a commit 01ee932

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

lib/__tests__/react-most-test.jsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import ReactDOM from 'react-dom';
33
import TestUtils from 'react-addons-test-utils';
44
import * as most from 'most';
55
import {compose} from 'ramda';
6-
import Most, {connect} from 'react-most';
6+
import Most, {connect} from '../react-most';
77
import {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}>

lib/react-most.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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){

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
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
},

0 commit comments

Comments
 (0)