@@ -23,16 +23,16 @@ describe('createAction()', () => {
2323 } ) ;
2424 } ) ;
2525
26- it ( 'should throw an error if payloadCreator is not a function or undefined' , ( ) => {
27- const wrongTypePayloadCreators = [ 1 , false , null , 'string' , { } , [ ] ] ;
26+ it ( 'should throw an error if payloadCreator is not a function, undefined, null ' , ( ) => {
27+ const wrongTypePayloadCreators = [ 1 , false , 'string' , { } , [ ] ] ;
2828
2929 wrongTypePayloadCreators . forEach ( wrongTypePayloadCreator => {
3030 expect ( ( ) => {
3131 createAction ( type , wrongTypePayloadCreator ) ;
3232 } )
3333 . to . throw (
3434 Error ,
35- 'Expected payloadCreator to be a function or undefined '
35+ 'Expected payloadCreator to be a function, undefined or null '
3636 ) ;
3737 } ) ;
3838 } ) ;
@@ -48,6 +48,17 @@ describe('createAction()', () => {
4848 expect ( isFSA ( action ) ) . to . be . true ;
4949 } ) ;
5050
51+ it ( 'uses identity function if payloadCreator is null' , ( ) => {
52+ const actionCreator = createAction ( type , null ) ;
53+ const foobar = { foo : 'bar' } ;
54+ const action = actionCreator ( foobar ) ;
55+ expect ( action ) . to . deep . equal ( {
56+ type,
57+ payload : foobar
58+ } ) ;
59+ expect ( isFSA ( action ) ) . to . be . true ;
60+ } ) ;
61+
5162 it ( 'accepts a second parameter for adding meta to object' , ( ) => {
5263 const actionCreator = createAction ( type , undefined , ( { cid } ) => ( { cid } ) ) ;
5364 const foobar = { foo : 'bar' , cid : 5 } ;
0 commit comments