1
- import React from 'react' ;
1
+ import React , { PropTypes } from 'react' ;
2
2
import { createStore } from 'redux' ;
3
3
import { Connector } from '../../src' ;
4
4
import storeShape from '../../src/utils/storeShape' ;
5
5
import { shallow , mount } from 'enzyme' ;
6
- import expect , { createSpy , spyOn } from 'expect' ;
6
+ import expect , { spyOn } from 'expect' ;
7
7
8
8
describe ( 'Connector' , function ( ) {
9
9
describe ( '.reduce' , function ( ) {
@@ -62,12 +62,13 @@ describe('Connector', function() {
62
62
describe ( '<Connector />' , function ( ) {
63
63
const store = createStore ( state => state ) ;
64
64
const Provider = React . createClass ( {
65
+ propTypes : { children : PropTypes . node } ,
65
66
childContextTypes : { store : storeShape } ,
66
- getChildContext ( ) { return { store } } ,
67
- render ( ) { return this . props . children }
67
+ getChildContext ( ) { return { store } ; } ,
68
+ render ( ) { return this . props . children ; }
68
69
} ) ;
69
70
class Connection extends React . Component {
70
- render ( ) { return < div className = "connection" /> }
71
+ render ( ) { return < div className = "connection" /> ; }
71
72
}
72
73
73
74
describe ( 'initialization' , function ( ) {
@@ -76,7 +77,7 @@ describe('<Connector />', function() {
76
77
}
77
78
78
79
it ( 'throws an error if store is undefined' , function ( ) {
79
- expect ( function ( ) { shallow ( < TestConnector /> ) } )
80
+ expect ( function ( ) { shallow ( < TestConnector /> ) ; } )
80
81
. toThrow ( 'TestConnector instance expects store object in props or in context' ) ;
81
82
} ) ;
82
83
@@ -87,7 +88,7 @@ describe('<Connector />', function() {
87
88
88
89
it ( 'accepts store from context' , function ( ) {
89
90
let instance = null ;
90
- const wrapper = mount ( < Provider > < TestConnector ref = { ( inst ) => instance = inst } /> </ Provider > ) ;
91
+ mount ( < Provider > < TestConnector ref = { ( inst ) => instance = inst } /> </ Provider > ) ;
91
92
expect ( instance . store ) . toBe ( store ) ;
92
93
} ) ;
93
94
} ) ;
@@ -193,12 +194,12 @@ describe('<Connector />', function() {
193
194
class TestConnector extends Connector {
194
195
static $connection = Connection ;
195
196
static $state = [ ] ;
196
- static $reducer = TestConnector . reduce ( 'foo' , ( state ) => ( { } ) ) ;
197
+ static $reducer = TestConnector . reduce ( 'foo' , ( ) => ( { } ) ) ;
197
198
}
198
199
199
200
it ( 'throws an error' , function ( ) {
200
201
const store = createStore ( TestConnector . $reducer ) ;
201
- expect ( function ( ) { mount ( < TestConnector store = { store } /> ) } )
202
+ expect ( function ( ) { mount ( < TestConnector store = { store } /> ) ; } )
202
203
. toThrow ( 'TestConnector.$state should be a plain object' +
203
204
'or there should be a $expose instance method defined that returns a plain object'
204
205
) ;
@@ -209,13 +210,13 @@ describe('<Connector />', function() {
209
210
class TestConnector extends Connector {
210
211
static $connection = Connection ;
211
212
static $state = { items : [ ] } ;
212
- static $reducer = TestConnector . reduce ( 'foo' , ( state ) => ( { } ) ) ;
213
- $expose ( $state ) { return $state . items }
213
+ static $reducer = TestConnector . reduce ( 'foo' , ( ) => ( { } ) ) ;
214
+ $expose ( $state ) { return $state . items ; }
214
215
}
215
216
216
217
it ( 'throws an error' , function ( ) {
217
218
const store = createStore ( TestConnector . $reducer ) ;
218
- expect ( function ( ) { mount ( < TestConnector store = { store } /> ) } )
219
+ expect ( function ( ) { mount ( < TestConnector store = { store } /> ) ; } )
219
220
. toThrow ( 'TestConnector.$state should be a plain object' +
220
221
'or there should be a $expose instance method defined that returns a plain object'
221
222
) ;
@@ -310,7 +311,7 @@ describe('<Connector />', function() {
310
311
it ( 'throws an error when no connection is specified' , function ( ) {
311
312
class BadConnector extends Connector { }
312
313
313
- expect ( function ( ) { mount ( < BadConnector store = { store } /> ) } )
314
+ expect ( function ( ) { mount ( < BadConnector store = { store } /> ) ; } )
314
315
. toThrow ( 'BadConnector should define a $connection class property' ) ;
315
316
} ) ;
316
317
0 commit comments