@@ -1881,6 +1881,43 @@ describe('React', () => {
18811881 expect ( memoizedReturnCount ) . toBe ( 2 )
18821882 } )
18831883
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+
18841921 it ( 'should allow providing a factory function to mapDispatchToProps' , ( ) => {
18851922 let updatedCount = 0
18861923 let memoizedReturnCount = 0
@@ -2134,7 +2171,7 @@ describe('React', () => {
21342171 class BlockUpdates extends Component {
21352172 shouldComponentUpdate ( ) { return false ; }
21362173 render ( ) { return this . props . children ; }
2137- }
2174+ }
21382175
21392176 const mapStateToProps = expect . createSpy ( ) . andCall ( state => ( { count : state } ) )
21402177 @connect ( mapStateToProps )
@@ -2169,6 +2206,6 @@ describe('React', () => {
21692206
21702207 store . dispatch ( { type : 'INC' } )
21712208 } )
2172-
2209+
21732210 } )
21742211} )
0 commit comments