@@ -24,6 +24,9 @@ describe('React', () => {
24
24
return Children . only ( this . props . children )
25
25
}
26
26
}
27
+ ProviderMock . childContextTypes = {
28
+ store : PropTypes . object . isRequired
29
+ }
27
30
28
31
class ContextBoundStore {
29
32
constructor ( reducer ) {
@@ -49,10 +52,6 @@ describe('React', () => {
49
52
}
50
53
}
51
54
52
- ProviderMock . childContextTypes = {
53
- store : PropTypes . object . isRequired
54
- }
55
-
56
55
function stringBuilder ( prev = '' , action ) {
57
56
return action . type === 'APPEND'
58
57
? prev + action . body
@@ -2083,6 +2082,48 @@ describe('React', () => {
2083
2082
store . dispatch ( { type : 'ACTION' } )
2084
2083
expect ( renderCount ) . toBe ( rendersBeforeStateChange + 1 )
2085
2084
} )
2086
- } )
2087
2085
2086
+ function renderWithBadConnect ( Component ) {
2087
+ const store = createStore ( ( ) => ( { } ) )
2088
+
2089
+ try {
2090
+ TestUtils . renderIntoDocument (
2091
+ < ProviderMock store = { store } >
2092
+ < Component pass = "through" />
2093
+ </ ProviderMock >
2094
+ )
2095
+ return null
2096
+ } catch ( error ) {
2097
+ return error . message
2098
+ }
2099
+ }
2100
+ it ( 'should throw a helpful error for invalid mapStateToProps arguments' , ( ) => {
2101
+ @connect ( 'invalid' )
2102
+ class InvalidMapState extends React . Component { render ( ) { return < div > </ div > } }
2103
+
2104
+ const error = renderWithBadConnect ( InvalidMapState )
2105
+ expect ( error ) . toInclude ( 'string' )
2106
+ expect ( error ) . toInclude ( 'mapStateToProps' )
2107
+ expect ( error ) . toInclude ( 'InvalidMapState' )
2108
+ } )
2109
+ it ( 'should throw a helpful error for invalid mapDispatchToProps arguments' , ( ) => {
2110
+ @connect ( null , 'invalid' )
2111
+ class InvalidMapDispatch extends React . Component { render ( ) { return < div > </ div > } }
2112
+
2113
+ const error = renderWithBadConnect ( InvalidMapDispatch )
2114
+ expect ( error ) . toInclude ( 'string' )
2115
+ expect ( error ) . toInclude ( 'mapDispatchToProps' )
2116
+ expect ( error ) . toInclude ( 'InvalidMapDispatch' )
2117
+ } )
2118
+ it ( 'should throw a helpful error for invalid mergeProps arguments' , ( ) => {
2119
+ @connect ( null , null , 'invalid' )
2120
+ class InvalidMerge extends React . Component { render ( ) { return < div > </ div > } }
2121
+
2122
+ const error = renderWithBadConnect ( InvalidMerge )
2123
+ expect ( error ) . toInclude ( 'string' )
2124
+ expect ( error ) . toInclude ( 'mergeProps' )
2125
+ expect ( error ) . toInclude ( 'InvalidMerge' )
2126
+ } )
2127
+
2128
+ } )
2088
2129
} )
0 commit comments