1- import { createAtomActivity } from './atom-activity' ;
1+ import { createAtomActivity , createAtomActivityFromHandler } from './atom-activity' ;
22import { createActivitySet } from '../../core/activity-set' ;
33import { createWorkflowMachineBuilder } from '../../workflow-machine-builder' ;
44import { STATE_FINISHED_ID , STATE_INTERRUPTED_ID , STATE_FAILED_ID } from '../../types' ;
@@ -17,34 +17,21 @@ interface SetCounterStep extends Step {
1717}
1818
1919const activitySet = createActivitySet < TestGlobalState > ( [
20- createAtomActivity < SetCounterStep , TestGlobalState , { x : number } > ( {
21- stepType : 'setCounter' ,
20+ createAtomActivity < SetCounterStep , TestGlobalState , { x : number } > ( 'setCounter' , {
2221 init : ( ) => ( { x : 987654321 } ) ,
2322 handler : async ( step , globalState , activityState ) => {
2423 expect ( activityState . x ) . toBe ( 987654321 ) ;
2524 globalState . counter = step . properties . value ;
2625 }
2726 } ) ,
28- createAtomActivity < Step , TestGlobalState , null > ( {
29- stepType : 'multiply2' ,
30- init : ( ) => null ,
31- handler : async ( _ , globalState ) => {
32- globalState . counter *= 2 ;
33- }
27+ createAtomActivityFromHandler < Step , TestGlobalState > ( 'multiply2' , async ( _ , globalState ) => {
28+ globalState . counter *= 2 ;
3429 } ) ,
35- createAtomActivity < Step , TestGlobalState , null > ( {
36- stepType : 'interrupt' ,
37- init : ( ) => null ,
38- handler : async ( ) => {
39- return interrupt ( ) ;
40- }
30+ createAtomActivityFromHandler < Step , TestGlobalState > ( 'interrupt' , async ( ) => {
31+ return interrupt ( ) ;
4132 } ) ,
42- createAtomActivity < Step , TestGlobalState , null > ( {
43- stepType : 'error' ,
44- init : ( ) => null ,
45- handler : async ( ) => {
46- throw new Error ( 'TEST_ERROR' ) ;
47- }
33+ createAtomActivityFromHandler < Step , TestGlobalState > ( 'error' , async ( ) => {
34+ throw new Error ( 'TEST_ERROR' ) ;
4835 } )
4936] ) ;
5037
0 commit comments