File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 1
- import { bindActionCreators , createStore } from '../ '
1
+ import { bindActionCreators , createStore , ActionCreator } from '..'
2
2
import { todos } from './helpers/reducers'
3
3
import * as actionCreators from './helpers/actionCreators'
4
4
@@ -46,15 +46,17 @@ describe('bindActionCreators', () => {
46
46
} )
47
47
48
48
it ( 'skips non-function values in the passed object' , ( ) => {
49
+ // as this is testing against invalid values, we will cast to unknown and then back to ActionCreator<any>
50
+ // in a typescript environment this test is unnecessary, but required in javascript
49
51
const boundActionCreators = bindActionCreators (
50
- {
52
+ ( {
51
53
...actionCreators ,
52
54
foo : 42 ,
53
55
bar : 'baz' ,
54
56
wow : undefined ,
55
57
much : { } ,
56
58
test : null
57
- } ,
59
+ } as unknown ) as ActionCreator < any > ,
58
60
store . dispatch
59
61
)
60
62
expect ( Object . keys ( boundActionCreators ) ) . toEqual (
@@ -91,7 +93,10 @@ describe('bindActionCreators', () => {
91
93
92
94
it ( 'throws for a primitive actionCreator' , ( ) => {
93
95
expect ( ( ) => {
94
- bindActionCreators ( 'string' , store . dispatch )
96
+ bindActionCreators (
97
+ ( 'string' as unknown ) as ActionCreator < any > ,
98
+ store . dispatch
99
+ )
95
100
} ) . toThrow (
96
101
'bindActionCreators expected an object or a function, instead received string. ' +
97
102
'Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?'
You can’t perform that action at this time.
0 commit comments