File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -425,4 +425,37 @@ describe('createReduxEnhancer', () => {
425425 expect ( mockHint . attachments ) . toHaveLength ( 0 ) ;
426426 } ) ;
427427 } ) ;
428+
429+ it ( 'restore itself when calling store replaceReducer' , ( ) => {
430+ const enhancer = createReduxEnhancer ( ) ;
431+
432+ const initialState = { } ;
433+
434+ const ACTION_TYPE = 'UPDATE_VALUE' ;
435+ const reducer = ( state : Record < string , unknown > = initialState , action : { type : string ; newValue : any } ) => {
436+ if ( action . type === ACTION_TYPE ) {
437+ return {
438+ ...state ,
439+ value : action . newValue ,
440+ } ;
441+ }
442+ return state ;
443+ } ;
444+
445+ const store = Redux . createStore ( reducer , enhancer ) ;
446+
447+ store . replaceReducer ( reducer ) ;
448+
449+ const updateAction = { type : ACTION_TYPE , newValue : 'updated' } ;
450+ store . dispatch ( updateAction ) ;
451+
452+ expect ( mockSetContext ) . toBeCalledWith ( 'state' , {
453+ state : {
454+ type : 'redux' ,
455+ value : {
456+ value : 'updated' ,
457+ } ,
458+ } ,
459+ } ) ;
460+ } ) ;
428461} ) ;
You can’t perform that action at this time.
0 commit comments