@@ -1881,6 +1881,43 @@ describe('React', () => {
1881
1881
expect ( memoizedReturnCount ) . toBe ( 2 )
1882
1882
} )
1883
1883
1884
+ it ( 'should allow a mapStateToProps factory consuming just state to return a function that gets ownProps' , ( ) => {
1885
+ const store = createStore ( ( ) => ( { value : 1 } ) )
1886
+
1887
+ let initialState
1888
+ let initialOwnProps
1889
+ let secondaryOwnProps
1890
+ const mapStateFactory = function ( factoryInitialState ) {
1891
+ initialState = factoryInitialState
1892
+ initialOwnProps = arguments [ 1 ] ;
1893
+ return ( state , props ) => {
1894
+ secondaryOwnProps = props
1895
+ return { }
1896
+ }
1897
+ }
1898
+
1899
+ @connect ( mapStateFactory )
1900
+ class Container extends Component {
1901
+ render ( ) {
1902
+ return < Passthrough { ...this . props } />
1903
+ }
1904
+ }
1905
+
1906
+ TestUtils . renderIntoDocument (
1907
+ < ProviderMock store = { store } >
1908
+ < div >
1909
+ < Container name = "a" />
1910
+ </ div >
1911
+ </ ProviderMock >
1912
+ )
1913
+
1914
+ store . dispatch ( { type : 'test' } )
1915
+ expect ( initialOwnProps ) . toBe ( undefined )
1916
+ expect ( initialState ) . toNotBe ( undefined )
1917
+ expect ( secondaryOwnProps ) . toNotBe ( undefined )
1918
+ expect ( secondaryOwnProps . name ) . toBe ( "a" )
1919
+ } )
1920
+
1884
1921
it ( 'should allow providing a factory function to mapDispatchToProps' , ( ) => {
1885
1922
let updatedCount = 0
1886
1923
let memoizedReturnCount = 0
@@ -2134,7 +2171,7 @@ describe('React', () => {
2134
2171
class BlockUpdates extends Component {
2135
2172
shouldComponentUpdate ( ) { return false ; }
2136
2173
render ( ) { return this . props . children ; }
2137
- }
2174
+ }
2138
2175
2139
2176
const mapStateToProps = expect . createSpy ( ) . andCall ( state => ( { count : state } ) )
2140
2177
@connect ( mapStateToProps )
@@ -2169,6 +2206,6 @@ describe('React', () => {
2169
2206
2170
2207
store . dispatch ( { type : 'INC' } )
2171
2208
} )
2172
-
2209
+
2173
2210
} )
2174
2211
} )
0 commit comments