Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita4fd5de

Browse files
committed
unit test route reducer
1 parent54d46e5 commita4fd5de

File tree

5 files changed

+31
-49
lines changed

5 files changed

+31
-49
lines changed

‎src/modules/route/MenuLink/index.tsx

Lines changed: 0 additions & 27 deletions
This file was deleted.

‎src/modules/route/RouteButton/index.tsx

Lines changed: 0 additions & 22 deletions
This file was deleted.

‎src/modules/route/actions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import{ROUTE_SET}from'./types';
22

3+
/**
4+
* Sets a route
5+
*@param {string} route route name
6+
*@returns thunk
7+
*/
38
exportfunctionrouteSet(route:string):Redux.ThunkAction<any,any,{}>{
49
return(dispatch,getState)=>{
510
if(getState().route!==route){

‎src/modules/route/reducer.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
importroutefrom'./reducer';
2+
3+
describe('route reducer',()=>{
4+
5+
it('should set the initial route to "start"',()=>{
6+
constaction={type:'unknown'};
7+
expect(route(undefined,action)).toBe('start');
8+
});
9+
10+
it('should trigger route changes on ROUTE_SET',()=>{
11+
constaction={type:'ROUTE_SET',payload:{route:'next'}};
12+
expect(route(undefined,action)).toBe('next');
13+
});
14+
15+
it('maintains existing route if no change',()=>{
16+
constaction={type:'unknown'};
17+
expect(route('current',action)).toBe('current');
18+
});
19+
20+
});

‎src/modules/route/reducer.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import {ROUTE_SET} from './types';
22

33
const_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+
*/
511
exportdefaultfunctionrouteReducer(
612
route=_route,action:Action
713
):string{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp