This repository was archived by the owner on Apr 8, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +31
-49
lines changed Expand file tree Collapse file tree 5 files changed +31
-49
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11import { ROUTE_SET } from './types' ;
22
3+ /**
4+ * Sets a route
5+ * @param {string } route route name
6+ * @returns thunk
7+ */
38export function routeSet ( route : string ) : Redux . ThunkAction < any , any , { } > {
49 return ( dispatch , getState ) => {
510 if ( getState ( ) . route !== route ) {
Original file line number Diff line number Diff line change 1+ import route from './reducer' ;
2+
3+ describe ( 'route reducer' , ( ) => {
4+
5+ it ( 'should set the initial route to "start"' , ( ) => {
6+ const action = { type : 'unknown' } ;
7+ expect ( route ( undefined , action ) ) . toBe ( 'start' ) ;
8+ } ) ;
9+
10+ it ( 'should trigger route changes on ROUTE_SET' , ( ) => {
11+ const action = { type : 'ROUTE_SET' , payload : { route : 'next' } } ;
12+ expect ( route ( undefined , action ) ) . toBe ( 'next' ) ;
13+ } ) ;
14+
15+ it ( 'maintains existing route if no change' , ( ) => {
16+ const action = { type : 'unknown' } ;
17+ expect ( route ( 'current' , action ) ) . toBe ( 'current' ) ;
18+ } ) ;
19+
20+ } ) ;
Original file line number Diff line number Diff line change @@ -2,6 +2,12 @@ import {ROUTE_SET} from './types';
22
33const _route = 'start' ;
44
5+ /**
6+ * Sets the route name
7+ * @param { } route=_route route name
8+ * @param {Action } action redux action
9+ * @returns string route name
10+ */
511export default function routeReducer (
612 route = _route , action : Action
713) : string {
You can’t perform that action at this time.
0 commit comments