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 1
1
import { ROUTE_SET } from './types' ;
2
2
3
+ /**
4
+ * Sets a route
5
+ * @param {string } route route name
6
+ * @returns thunk
7
+ */
3
8
export function routeSet ( route : string ) : Redux . ThunkAction < any , any , { } > {
4
9
return ( dispatch , getState ) => {
5
10
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';
2
2
3
3
const _route = 'start' ;
4
4
5
+ /**
6
+ * Sets the route name
7
+ * @param { } route=_route route name
8
+ * @param {Action } action redux action
9
+ * @returns string route name
10
+ */
5
11
export default function routeReducer (
6
12
route = _route , action : Action
7
13
) : string {
You can’t perform that action at this time.
0 commit comments