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 '..'
22import { todos } from './helpers/reducers'
33import * as actionCreators from './helpers/actionCreators'
44
@@ -46,15 +46,17 @@ describe('bindActionCreators', () => {
4646 } )
4747
4848 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
4951 const boundActionCreators = bindActionCreators (
50- {
52+ ( {
5153 ...actionCreators ,
5254 foo : 42 ,
5355 bar : 'baz' ,
5456 wow : undefined ,
5557 much : { } ,
5658 test : null
57- } ,
59+ } as unknown ) as ActionCreator < any > ,
5860 store . dispatch
5961 )
6062 expect ( Object . keys ( boundActionCreators ) ) . toEqual (
@@ -91,7 +93,10 @@ describe('bindActionCreators', () => {
9193
9294 it ( 'throws for a primitive actionCreator' , ( ) => {
9395 expect ( ( ) => {
94- bindActionCreators ( 'string' , store . dispatch )
96+ bindActionCreators (
97+ ( 'string' as unknown ) as ActionCreator < any > ,
98+ store . dispatch
99+ )
95100 } ) . toThrow (
96101 'bindActionCreators expected an object or a function, instead received string. ' +
97102 'Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?'
You can’t perform that action at this time.
0 commit comments