11import { createAction } from '../' ;
2- import isPlainObject from 'lodash.isplainobject ' ;
2+ import { isFSA } from 'flux-standard-action ' ;
33
44describe ( 'createAction()' , ( ) => {
55 describe ( 'resulting action creator' , ( ) => {
66 const type = 'TYPE' ;
77
8- it ( 'returns plain object ' , ( ) => {
8+ it ( 'returns a valid FSA ' , ( ) => {
99 const actionCreator = createAction ( type , b => b ) ;
1010 const foobar = { foo : 'bar' } ;
1111 const action = actionCreator ( foobar ) ;
12- expect ( isPlainObject ( action ) ) . to . be . true ;
12+ expect ( isFSA ( action ) ) . to . be . true ;
1313 } ) ;
1414
1515 it ( 'uses return value as payload' , ( ) => {
16- const actionCreator = createAction ( type , b => b ) ;
17- const foobar = { foo : 'bar' } ;
18- const action = actionCreator ( foobar ) ;
19- expect ( action . payload ) . to . equal ( foobar ) ;
20- } ) ;
21-
22- it ( 'has no extraneous keys' , ( ) => {
2316 const actionCreator = createAction ( type , b => b ) ;
2417 const foobar = { foo : 'bar' } ;
2518 const action = actionCreator ( foobar ) ;
@@ -37,6 +30,7 @@ describe('createAction()', () => {
3730 type,
3831 payload : foobar
3932 } ) ;
33+ expect ( isFSA ( action ) ) . to . be . true ;
4034 } ) ;
4135
4236 it ( 'accepts a second parameter for adding meta to object' , ( ) => {
@@ -50,6 +44,7 @@ describe('createAction()', () => {
5044 cid : 5
5145 }
5246 } ) ;
47+ expect ( isFSA ( action ) ) . to . be . true ;
5348 } ) ;
5449
5550 it ( 'sets error to true if payload is an Error object' , ( ) => {
@@ -62,13 +57,15 @@ describe('createAction()', () => {
6257 payload : errObj ,
6358 error : true
6459 } ) ;
60+ expect ( isFSA ( errAction ) ) . to . be . true ;
6561
6662 const foobar = { foo : 'bar' , cid : 5 } ;
6763 const noErrAction = actionCreator ( foobar ) ;
6864 expect ( noErrAction ) . to . deep . equal ( {
6965 type,
7066 payload : foobar
7167 } ) ;
68+ expect ( isFSA ( noErrAction ) ) . to . be . true ;
7269 } ) ;
7370 } ) ;
7471} ) ;
0 commit comments