Skip to content

Commit de0c55a

Browse files
committed
use react-most-spec and depreticate test-util
1 parent d4d794d commit de0c55a

File tree

5 files changed

+31
-38
lines changed

5 files changed

+31
-38
lines changed

lib/__tests__/react-most-test.jsx

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ 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';
7-
import {sync,hold} from 'most-subject'
8-
import {from } from 'most'
9-
import {dispatch, stateHistoryOf, intentHistoryOf, Engine} from 'react-most-spec'
6+
import Most, {connect} from 'react-most';
7+
import {stateStreamOf, stateHistoryOf,
8+
intentStreamOf, intentHistoryOf,
9+
run, dispatch,
10+
Engine } from 'react-most-spec';
1011
const CounterView = React.createClass({
1112
render(){
1213
return (
@@ -227,7 +228,9 @@ describe('react-most', () => {
227228
sink$: intent$.map(intent=>{
228229
switch(intent.type) {
229230
case 'exception':
230-
throw new Error('exception in reducer')
231+
throw 'exception in reducer'
232+
case 'inc':
233+
return state=>({count:state.count+1})
231234
default:
232235
return state=>state
233236
}
@@ -240,14 +243,29 @@ describe('react-most', () => {
240243

241244
it('should recover to identity stream and log exception', ()=>{
242245
spyOn(console, 'error')
246+
let counterWrapper = TestUtils.renderIntoDocument(
247+
<Most>
248+
<Counter history={true} />
249+
</Most>
250+
)
251+
let counter = TestUtils.findRenderedComponentWithType(counterWrapper, Counter)
252+
return run(intentStreamOf(counter),
253+
dispatch([{type: 'exception'}], counter),
254+
[
255+
state=>expect(console.error).toBeCalledWith('There is Error in your reducer:', 'exception in reducer', undefined)
256+
])
257+
})
258+
259+
it('should able to catch error in sync mode', ()=>{
243260
let counterWrapper = TestUtils.renderIntoDocument(
244261
<Most engine={Engine}>
245262
<Counter history={true} />
246263
</Most>
247264
)
248265
let counter = TestUtils.findRenderedComponentWithType(counterWrapper, Counter)
249-
counter.actions.throwExeption()
250-
expect(console.error).toHaveBeenCalled()
266+
expect(()=>{
267+
counter.actions.throwExeption()
268+
}).toThrow('exception in reducer')
251269
})
252270
})
253271

lib/test-utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {from } from 'most'
22
import {INTENT_STREAM, HISTORY_STREAM} from './react-most'
3+
console.warn('react-most/test-utils is DEPRETICATED, please use react-most-spec instead.')
34
function getStreamOf(component, name) {
45
let s = from(component.context[name]);
56
s.take$ = n => s.take(n).forEach(_=>_)

node_modules/react-most

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"most-subject": "^5.2.0",
3232
"ramda": "^0.23.0",
3333
"react": "^15.3.2",
34-
"react-most-spec": "v0.1.2",
34+
"react-most-spec": "0.2.3",
3535
"rxjs": "^5.0.0-rc.4"
3636
},
3737
"jest": {

yarn.lock

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2170,18 +2170,6 @@ most-subject@^5.2.0:
21702170
"@most/prelude" "^1.4.1"
21712171
most "^1.1.0"
21722172

2173-
most-subject@^5.3.0:
2174-
version "5.3.0"
2175-
resolved "https://registry.yarnpkg.com/most-subject/-/most-subject-5.3.0.tgz#3a6e3efd436fa93bd8b33c2a239c9088230a6102"
2176-
dependencies:
2177-
"@most/multicast" "^1.2.4"
2178-
"@most/prelude" "^1.4.1"
2179-
most "^1.1.0"
2180-
2181-
most-test@^1.2.0:
2182-
version "1.2.0"
2183-
resolved "https://registry.yarnpkg.com/most-test/-/most-test-1.2.0.tgz#145f989f21eafc69774c7b23b6727e8a1761f1d5"
2184-
21852173
most@^1.1.0, most@^1.1.1:
21862174
version "1.1.1"
21872175
resolved "https://registry.yarnpkg.com/most/-/most-1.1.1.tgz#75ccbb4c61a086b6794c378583ae0113b20fc7b5"
@@ -2492,24 +2480,9 @@ react-dom@^15.3.2:
24922480
loose-envify "^1.1.0"
24932481
object-assign "^4.1.0"
24942482

2495-
react-most-spec@v0.1.2:
2496-
version "0.1.2"
2497-
resolved "https://registry.yarnpkg.com/react-most-spec/-/react-most-spec-0.1.2.tgz#cddb008b28ad7bfadaddae9d80f950b9eacc9f01"
2498-
dependencies:
2499-
most "^1.1.1"
2500-
most-subject "^5.3.0"
2501-
most-test "^1.2.0"
2502-
react-most "^0.6.6"
2503-
2504-
react-most@^0.6.6:
2505-
version "0.6.6"
2506-
resolved "https://registry.yarnpkg.com/react-most/-/react-most-0.6.6.tgz#ce5e3e55a5b09ad26f4ee2ede029c27e6fd4ff2d"
2507-
dependencies:
2508-
most "^1.1.1"
2509-
most-subject "^5.2.0"
2510-
ramda "^0.22.1"
2511-
react "^15.3.2"
2512-
rxjs "^5.0.0-rc.4"
2483+
react-most-spec@0.2.3:
2484+
version "0.2.3"
2485+
resolved "https://registry.yarnpkg.com/react-most-spec/-/react-most-spec-0.2.3.tgz#496fc9516688738d6964dfb2c31895c33074360a"
25132486

25142487
react@^15.3.2:
25152488
version "15.4.1"

0 commit comments

Comments
 (0)