File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ export default (...args) => {
10
10
}
11
11
12
12
return ( prevState , value , ...args ) => {
13
- const prevStateIsUndefined = typeof ( prevState === 'undefined' ) ;
13
+ const prevStateIsUndefined = typeof prevState === 'undefined' ;
14
14
const valueIsUndefined = typeof value === 'undefined' ;
15
15
16
16
if ( prevStateIsUndefined && valueIsUndefined && initialState ) {
Original file line number Diff line number Diff line change @@ -86,3 +86,22 @@ test('no initialState supplied + undefined state: initial state defined by first
86
86
87
87
expect ( reducerAB ( undefined , 3 ) ) . toEqual ( { A : 12 , B : 2 } ) ;
88
88
} ) ;
89
+
90
+ test ( 'actions should progressively update state' , ( ) => {
91
+ const reducerA = ( state , action ) => {
92
+ if ( action . type === 'A' ) return { ...state , a : true } ;
93
+ return state ;
94
+ } ;
95
+ const reducerB = ( state , action ) => {
96
+ if ( action . type === 'B' ) return { ...state , b : true } ;
97
+ return state ;
98
+ } ;
99
+ const initial = { a : false , b : false } ;
100
+ const combined = reduceReducers ( reducerA , reducerB , initial ) ;
101
+
102
+ let state = combined ( undefined , { type : 'A' } ) ;
103
+ expect ( state ) . toEqual ( { a : true , b : false } ) ;
104
+
105
+ state = combined ( state , { type : 'B' } ) ;
106
+ expect ( state ) . toEqual ( { a : true , b : true } ) ;
107
+ } ) ;
You can’t perform that action at this time.
0 commit comments