From 9e5f06b0f2cafccd67356a0f88c819cefc26c5c8 Mon Sep 17 00:00:00 2001 From: Jack Hsu Date: Tue, 15 Sep 2015 01:26:36 -0400 Subject: [PATCH] adds test for return type of actionHandler/reducer --- redux-actions/redux-actions-tests.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/redux-actions/redux-actions-tests.ts b/redux-actions/redux-actions-tests.ts index 68d93ff7b..53305a2c9 100644 --- a/redux-actions/redux-actions-tests.ts +++ b/redux-actions/redux-actions-tests.ts @@ -22,11 +22,13 @@ const action: ReduxActions.Action = incrementAction(42); amount => ({ remote: true }) ); +let state: number; + const actionHandler = ReduxActions.handleAction( 'INCREMENT', (state: number, action: ReduxActions.Action) => state + 1 ); -actionHandler(0, { type: 'INCREMENT' }); +state = actionHandler(0, { type: 'INCREMENT' }); const actionHandlerWithReduceMap = ReduxActions.handleAction( @@ -37,18 +39,18 @@ const actionHandlerWithReduceMap = ReduxActions.handleAction( throw(state: number) { return state } } ); -actionHandlerWithReduceMap(0, { type: 'INCREMENT' }); +state = actionHandlerWithReduceMap(0, { type: 'INCREMENT' }); const actionsHandler = ReduxActions.handleActions({ 'INCREMENT': (state: number, action: ReduxActions.Action) => state + 1, 'DECREMENT': (state: number, action: ReduxActions.Action) => state - 1 }); -actionsHandler(0, { type: 'INCREMENT' }); +state = actionsHandler(0, { type: 'INCREMENT' }); const actionsHandlerWithInitialState = ReduxActions.handleActions({ 'INCREMENT': (state: number, action: ReduxActions.Action) => state + 1, 'DECREMENT': (state: number, action: ReduxActions.Action) => state - 1 }, 0); -actionsHandlerWithInitialState(0, { type: 'INCREMENT' }); +state = actionsHandlerWithInitialState(0, { type: 'INCREMENT' });