File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
Expand file tree Collapse file tree 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) {
2929
3030 switch ( action . type ) {
3131 case PUSH_ROUTE :
32+ if ( state . routes [ state . index ] . key === ( action . payload && action . payload . route . key ) ) return state ;
3233 return StateUtils . push ( state , action . payload . route ) ;
3334 case POP_ROUTE :
3435 return StateUtils . pop ( state ) ;
Original file line number Diff line number Diff line change @@ -21,6 +21,11 @@ const cardStackInitialState = {
2121 } ]
2222} ;
2323
24+ const repeatedRoute = {
25+ key : 'route-1' ,
26+ title : 'Route 1'
27+ } ;
28+
2429const tabInitialState = {
2530 key : 'ta-key' ,
2631 index : 0 ,
@@ -151,6 +156,14 @@ describe('reducers', () => {
151156 expect ( returnValue ) . to . equal ( 'StateUtils.push' ) ;
152157 } ) ;
153158
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+
154167 it ( 'does not call RN\'s StateUtils.push when pushRoute action has payload.key different from state.key and returns current nav state' , ( ) => {
155168 const action = pushRoute ( { key : 'route' } , 'nav' ) ;
156169
You can’t perform that action at this time.
0 commit comments