Skip to content

Commit 9e5f06b

Browse files
committed
adds test for return type of actionHandler/reducer
1 parent c491b84 commit 9e5f06b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

redux-actions/redux-actions-tests.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ const action: ReduxActions.Action = incrementAction(42);
2222
amount => ({ remote: true })
2323
);
2424

25+
let state: number;
26+
2527
const actionHandler = ReduxActions.handleAction(
2628
'INCREMENT',
2729
(state: number, action: ReduxActions.Action) => state + 1
2830
);
29-
actionHandler(0, { type: 'INCREMENT' });
31+
state = actionHandler(0, { type: 'INCREMENT' });
3032

3133

3234
const actionHandlerWithReduceMap = ReduxActions.handleAction(
@@ -37,18 +39,18 @@ const actionHandlerWithReduceMap = ReduxActions.handleAction(
3739
throw(state: number) { return state }
3840
}
3941
);
40-
actionHandlerWithReduceMap(0, { type: 'INCREMENT' });
42+
state = actionHandlerWithReduceMap(0, { type: 'INCREMENT' });
4143

4244
const actionsHandler = ReduxActions.handleActions<number>({
4345
'INCREMENT': (state: number, action: ReduxActions.Action) => state + 1,
4446
'DECREMENT': (state: number, action: ReduxActions.Action) => state - 1
4547
});
46-
actionsHandler(0, { type: 'INCREMENT' });
48+
state = actionsHandler(0, { type: 'INCREMENT' });
4749

4850
const actionsHandlerWithInitialState = ReduxActions.handleActions<number>({
4951
'INCREMENT': (state: number, action: ReduxActions.Action) => state + 1,
5052
'DECREMENT': (state: number, action: ReduxActions.Action) => state - 1
5153
}, 0);
52-
actionsHandlerWithInitialState(0, { type: 'INCREMENT' });
54+
state = actionsHandlerWithInitialState(0, { type: 'INCREMENT' });
5355

5456

0 commit comments

Comments
 (0)