@@ -14,7 +14,7 @@ interface IAppState {
14
14
instanceProperty ?: string ;
15
15
}
16
16
17
- type PayloadAction = Action & { payload : IAppState } ;
17
+ type PayloadAction = Action & { payload ? : IAppState } ;
18
18
19
19
describe ( '@dispatch' , ( ) => {
20
20
let ngRedux ;
@@ -31,7 +31,7 @@ describe('@dispatch', () => {
31
31
rootReducer = ( state = defaultState , action : PayloadAction ) => {
32
32
switch ( action . type ) {
33
33
case 'TEST' :
34
- const { value, instanceProperty } = action . payload ;
34
+ const { value = null , instanceProperty = null } = action . payload || { } ;
35
35
return Object . assign ( { } , state , { value, instanceProperty } ) ;
36
36
default :
37
37
return state ;
@@ -78,8 +78,8 @@ describe('@dispatch', () => {
78
78
}
79
79
} ;
80
80
expect ( result . type ) . toBe ( 'TEST' ) ;
81
- expect ( result . payload . value ) . toBe ( 'class method' ) ;
82
- expect ( result . payload . instanceProperty ) . toBe ( 'test' ) ;
81
+ expect ( result . payload && result . payload . value ) . toBe ( 'class method' ) ;
82
+ expect ( result . payload && result . payload . instanceProperty ) . toBe ( 'test' ) ;
83
83
expect ( NgRedux . instance ) . toBeTruthy ( ) ;
84
84
expect ( NgRedux . instance && NgRedux . instance . dispatch )
85
85
. toHaveBeenCalledWith ( expectedArgs )
@@ -95,8 +95,8 @@ describe('@dispatch', () => {
95
95
}
96
96
}
97
97
expect ( result . type ) . toBe ( 'TEST' ) ;
98
- expect ( result . payload . value ) . toBe ( 'bound property' ) ;
99
- expect ( result . payload . instanceProperty ) . toBe ( 'test' ) ;
98
+ expect ( result . payload && result . payload . value ) . toBe ( 'bound property' ) ;
99
+ expect ( result . payload && result . payload . instanceProperty ) . toBe ( 'test' ) ;
100
100
expect ( NgRedux . instance ) . toBeTruthy ( ) ;
101
101
expect ( NgRedux . instance && NgRedux . instance . dispatch )
102
102
. toHaveBeenCalledWith ( expectedArgs )
@@ -123,8 +123,8 @@ describe('@dispatch', () => {
123
123
}
124
124
}
125
125
expect ( result . type ) . toBe ( 'TEST' ) ;
126
- expect ( result . payload . value ) . toBe ( 'external function' ) ;
127
- expect ( result . payload . instanceProperty ) . toBe ( 'test' ) ;
126
+ expect ( result . payload && result . payload . value ) . toBe ( 'external function' ) ;
127
+ expect ( result . payload && result . payload . instanceProperty ) . toBe ( 'test' ) ;
128
128
expect ( NgRedux . instance ) . toBeTruthy ( ) ;
129
129
expect ( NgRedux . instance && NgRedux . instance . dispatch )
130
130
. toHaveBeenCalledWith ( expectedArgs )
0 commit comments