File tree 2 files changed +14
-0
lines changed
2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ export function cardStackReducer(initialState) {
29
29
30
30
switch ( action . type ) {
31
31
case PUSH_ROUTE :
32
+ if ( state . routes [ state . index ] . key === ( action . payload && action . payload . route . key ) ) return state ;
32
33
return StateUtils . push ( state , action . payload . route ) ;
33
34
case POP_ROUTE :
34
35
return StateUtils . pop ( state ) ;
Original file line number Diff line number Diff line change @@ -21,6 +21,11 @@ const cardStackInitialState = {
21
21
} ]
22
22
} ;
23
23
24
+ const repeatedRoute = {
25
+ key : 'route-1' ,
26
+ title : 'Route 1'
27
+ } ;
28
+
24
29
const tabInitialState = {
25
30
key : 'ta-key' ,
26
31
index : 0 ,
@@ -151,6 +156,14 @@ describe('reducers', () => {
151
156
expect ( returnValue ) . to . equal ( 'StateUtils.push' ) ;
152
157
} ) ;
153
158
159
+ it ( 'does not call RN\'s StateUtils.push when pushRoute action has payload.key same with current route state.key and returns current nav state' , ( ) => {
160
+ const action = pushRoute ( { key : 'route' } , repeatedRoute . key ) ;
161
+
162
+ const returnValue = reducer ( cardStackInitialState , action ) ;
163
+ expect ( pushSpy . callCount ) . to . equal ( 0 ) ;
164
+ expect ( returnValue ) . to . equal ( cardStackInitialState ) ;
165
+ } ) ;
166
+
154
167
it ( 'does not call RN\'s StateUtils.push when pushRoute action has payload.key different from state.key and returns current nav state' , ( ) => {
155
168
const action = pushRoute ( { key : 'route' } , 'nav' ) ;
156
169
You can’t perform that action at this time.
0 commit comments