@@ -2912,6 +2912,57 @@ describe('React', () => {
29122912 expect . stringContaining ( 'was not wrapped in act' )
29132913 )
29142914 }
2915+
2916+ spy . mockRestore ( )
2917+ } )
2918+
2919+ it ( 'should warn one-time-only that `pure` options has been removed' , ( ) => {
2920+ const spy = jest . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } )
2921+ const store : Store = createStore ( stringBuilder )
2922+
2923+ class ContainerA extends Component {
2924+ render ( ) {
2925+ return < Passthrough { ...this . props } />
2926+ }
2927+ }
2928+
2929+ const ConnectedContainerA = connect (
2930+ ( state ) => ( { string : state } ) ,
2931+ ( ) => ( { } ) ,
2932+ ( ) => ( { } ) ,
2933+ // The `pure` option has been removed
2934+ // @ts -ignore
2935+ { pure : true }
2936+ ) ( ContainerA )
2937+
2938+ class ContainerB extends Component {
2939+ render ( ) {
2940+ return < Passthrough { ...this . props } />
2941+ }
2942+ }
2943+
2944+ const ConnectedContainerB = connect (
2945+ ( state ) => ( { string : state } ) ,
2946+ ( ) => ( { } ) ,
2947+ ( ) => ( { } ) ,
2948+ // The `pure` option has been removed
2949+ // @ts -ignore
2950+ { pure : true }
2951+ ) ( ContainerB )
2952+
2953+ rtl . render (
2954+ < ProviderMock store = { store } >
2955+ < ConnectedContainerA />
2956+ < ConnectedContainerB />
2957+ </ ProviderMock >
2958+ )
2959+
2960+ expect ( spy ) . toHaveBeenCalledTimes ( 1 )
2961+ expect ( spy ) . toHaveBeenCalledWith (
2962+ 'The `pure` option has been removed. `connect` is now always a "pure/memoized" component'
2963+ )
2964+
2965+ spy . mockRestore ( )
29152966 } )
29162967 } )
29172968
@@ -3236,9 +3287,13 @@ describe('React', () => {
32363287 </ ProviderMock >
32373288 )
32383289
3239- store . dispatch ( { type : '' } )
3240- store . dispatch ( { type : '' } )
3241- outerComponent . current ! . setState ( ( { count } ) => ( { count : count + 1 } ) )
3290+ rtl . act ( ( ) => {
3291+ store . dispatch ( { type : '' } )
3292+ store . dispatch ( { type : '' } )
3293+ outerComponent . current ! . setState ( ( { count } ) => ( {
3294+ count : count + 1 ,
3295+ } ) )
3296+ } )
32423297
32433298 expect ( reduxCountPassedToMapState ) . toEqual ( 3 )
32443299 } )
0 commit comments