11import {
22 SAVE_STATUSES ,
3+ DUPLICATE_STATUSES ,
34 DELETE_STATUSES ,
45 UI_ACTIONS ,
56 CURRENT_POD_ACTIONS ,
@@ -11,6 +12,7 @@ import {
1112 setSaveStatus ,
1213 setDeleteStatus ,
1314 setGroupSaveStatus ,
15+ setGroupDuplicateStatus ,
1416 setGroupDeleteStatus ,
1517 // @todo add Field tests:
1618 setFieldSaveStatus ,
@@ -27,6 +29,7 @@ import {
2729 savePod ,
2830 deletePod ,
2931 saveGroup ,
32+ duplicateGroup ,
3033 deleteGroup ,
3134
3235 // setGroupFields,
@@ -103,6 +106,24 @@ describe( 'actions', () => {
103106 expect ( result ) . toEqual ( expected ) ;
104107 } ) ;
105108
109+ test ( 'setGroupDuplicateStatus() creates a function to create an action to change the group\'s duplicate status' , ( ) => {
110+ const expected = {
111+ type : UI_ACTIONS . SET_GROUP_DUPLICATE_STATUS ,
112+ saveStatus : DUPLICATE_STATUSES . DUPLICATE_SUCCESS ,
113+ result : {
114+ message : 'Duplicated successfully.' ,
115+ } ,
116+ } ;
117+
118+ const result = setGroupDuplicateStatus (
119+ DUPLICATE_STATUSES . DUPLICATE_SUCCESS ,
120+ ) ( {
121+ message : 'Duplicated successfully.' ,
122+ } ) ;
123+
124+ expect ( result ) . toEqual ( expected ) ;
125+ } ) ;
126+
106127 test ( 'setGroupDeleteStatus() creates a function to create action to change the group\'s delete status' , ( ) => {
107128 const expected = {
108129 type : UI_ACTIONS . SET_GROUP_DELETE_STATUS ,
@@ -322,6 +343,18 @@ describe( 'actions', () => {
322343 expect ( result . payload . onStart ( ) . type ) . toEqual ( UI_ACTIONS . SET_GROUP_SAVE_STATUS ) ;
323344 } ) ;
324345
346+ test ( 'duplicateGroup() returns an action to duplicate a pod by its ID' , ( ) => {
347+ const action = CURRENT_POD_ACTIONS . API_REQUEST ;
348+
349+ const result = duplicateGroup ( 123 ) ;
350+
351+ expect ( result . type ) . toEqual ( action ) ;
352+ expect ( result . payload . onSuccess [ 0 ] ( ) . type ) . toEqual ( UI_ACTIONS . SET_GROUP_DUPLICATE_STATUS ) ;
353+ expect ( result . payload . onSuccess [ 1 ] ( ) . type ) . toEqual ( CURRENT_POD_ACTIONS . DUPLICATE_GROUP ) ;
354+ expect ( result . payload . onFailure ( ) . type ) . toEqual ( UI_ACTIONS . SET_GROUP_DUPLICATE_STATUS ) ;
355+ expect ( result . payload . onStart ( ) . type ) . toEqual ( UI_ACTIONS . SET_GROUP_DUPLICATE_STATUS ) ;
356+ } ) ;
357+
325358 test ( 'deleteGroup() returns an action to delete a group by its ID' , ( ) => {
326359 const action = CURRENT_POD_ACTIONS . API_REQUEST ;
327360
0 commit comments