@@ -6,13 +6,18 @@ import { SyncAction, ReducerBuilder, StoreBuilder } from '../src'
66interface SampleState {
77isSyncActionCalled :boolean
88isAsyncActionCalled ?:boolean
9+ testValue ?:string
910}
1011
1112interface SampleStore {
1213reducer :SampleState
1314}
1415
15- class SampleSyncAction extends SyncAction { }
16+ class SampleSyncAction extends SyncAction {
17+ constructor ( public value :string ) {
18+ super ( )
19+ }
20+ }
1621
1722class SampleAsyncAction extends SyncAction { }
1823
@@ -43,7 +48,7 @@ describe('Reducer', () => {
4348. withReducerBuilder ( 'reducer' , reducer )
4449. build ( )
4550
46- store . dispatch ( new SampleSyncAction ( ) )
51+ store . dispatch ( new SampleSyncAction ( 'test1' ) )
4752
4853it ( 'should be called on dispatch sync action' , ( ) => {
4954expect ( store . getState ( ) . reducer . isSyncActionCalled ) . equal ( true )
@@ -52,6 +57,7 @@ describe('Reducer', () => {
5257
5358describe ( 'with async action handler' , ( ) => {
5459const dispatchedEvents :any [ ] = [ ]
60+ const testValue = 'test'
5561let store :Store < SampleStore >
5662
5763before ( done => {
@@ -61,12 +67,12 @@ describe('Reducer', () => {
6167isAsyncActionCalled :false ,
6268} )
6369. handle ( SampleAsyncAction , ( state , action , dispatch ) => {
64- dispatch ( new SampleSyncAction ( ) )
70+ dispatch ( new SampleSyncAction ( testValue ) )
6571return { ...state , isAsyncActionCalled :true }
6672} )
6773. handle ( SampleSyncAction , ( state , action ) => {
6874setTimeout ( done )
69- return { ...state , isSyncActionCalled :true }
75+ return { ...state , isSyncActionCalled :true , testValue : action . value }
7076} )
7177
7278store = new StoreBuilder < SampleStore > ( )
@@ -96,5 +102,9 @@ describe('Reducer', () => {
96102it ( 'should handle async action' , ( ) => {
97103expect ( store . getState ( ) . reducer . isAsyncActionCalled ) . equal ( true )
98104} )
105+
106+ it ( 'should pass correct parameter value' , ( ) => {
107+ expect ( store . getState ( ) . reducer . testValue ) . equal ( testValue )
108+ } )
99109} )
100110} )