@@ -221,6 +221,98 @@ describe('React', () => {
221221 ...TestUtils . findRenderedDOMComponentWithTag ( container , 'div' ) . props
222222 } ;
223223
224+ expect ( propsBefore . x ) . toEqual ( true ) ;
225+ expect ( 'x' in propsAfter ) . toEqual ( false , 'x prop must be removed' ) ;
226+ } ) ;
227+
228+ it ( 'should remove undefined props without mapDispatchToProps' , ( ) => {
229+ const store = createStore ( ( ) => ( { } ) ) ;
230+ let props = { x : true } ;
231+ let container ;
232+
233+ @connect ( ( ) => ( { } ) )
234+ class ConnectContainer extends Component {
235+ render ( ) {
236+ return (
237+ < div { ...this . props } />
238+ ) ;
239+ }
240+ }
241+
242+ class HolderContainer extends Component {
243+ render ( ) {
244+ return (
245+ < ConnectContainer { ...props } />
246+ ) ;
247+ }
248+ }
249+
250+ TestUtils . renderIntoDocument (
251+ < Provider store = { store } >
252+ { ( ) => (
253+ < HolderContainer ref = { instance => container = instance } />
254+ ) }
255+ </ Provider >
256+ ) ;
257+
258+ const propsBefore = {
259+ ...TestUtils . findRenderedDOMComponentWithTag ( container , 'div' ) . props
260+ } ;
261+
262+ props = { } ;
263+ container . forceUpdate ( ) ;
264+
265+ const propsAfter = {
266+ ...TestUtils . findRenderedDOMComponentWithTag ( container , 'div' ) . props
267+ } ;
268+
269+ expect ( propsBefore . x ) . toEqual ( true ) ;
270+ expect ( 'x' in propsAfter ) . toEqual ( false , 'x prop must be removed' ) ;
271+ } ) ;
272+
273+ it ( 'should remove undefined props without mapDispatchToProps' , ( ) => {
274+ // in this failing test connect doesn't call render second time
275+ // i can't understand why
276+ const store = createStore ( ( ) => ( { } ) ) ;
277+ let props = { x : true } ;
278+ let container ;
279+
280+ @connect ( ( ) => ( { } ) )
281+ class ConnectContainer extends Component {
282+ render ( ) {
283+ return (
284+ < div { ...this . props } />
285+ ) ;
286+ }
287+ }
288+
289+ class HolderContainer extends Component {
290+ render ( ) {
291+ return (
292+ < ConnectContainer { ...props } />
293+ ) ;
294+ }
295+ }
296+
297+ TestUtils . renderIntoDocument (
298+ < Provider store = { store } >
299+ { ( ) => (
300+ < HolderContainer ref = { instance => container = instance } />
301+ ) }
302+ </ Provider >
303+ ) ;
304+
305+ const propsBefore = {
306+ ...TestUtils . findRenderedDOMComponentWithTag ( container , 'div' ) . props
307+ } ;
308+
309+ props = { } ;
310+ container . forceUpdate ( ) ;
311+
312+ const propsAfter = {
313+ ...TestUtils . findRenderedDOMComponentWithTag ( container , 'div' ) . props
314+ } ;
315+
224316 expect ( propsBefore . x ) . toEqual ( true ) ;
225317 expect ( propsAfter . x ) . toNotEqual ( true ) ;
226318 } ) ;
0 commit comments