@@ -43,7 +43,7 @@ describe('mermaidState', () => {
43
43
}` )
44
44
)
45
45
) . sourceCode ( )
46
- ) . toBe ( `ParallelExec : ParallelExec
46
+ ) . toBe ( `ParallelExec : Parallel Exec
47
47
ParallelExec : type = Parallel State
48
48
ParallelExec : Completion type = allOf
49
49
ParallelExec : Num. of branches = 2
@@ -72,7 +72,7 @@ ParallelExec --> [*]`);
72
72
}` )
73
73
) ;
74
74
const mermaidState = new MermaidState ( eventbasedswitch ) ;
75
- expect ( mermaidState . sourceCode ( ) ) . toBe ( `CheckVisaStatus : CheckVisaStatus
75
+ expect ( mermaidState . sourceCode ( ) ) . toBe ( `CheckVisaStatus : Check Visa Status
76
76
CheckVisaStatus : type = Switch State
77
77
CheckVisaStatus : Condition type = event-based
78
78
CheckVisaStatus --> HandleApprovedVisa : visaApprovedEvent
@@ -101,7 +101,7 @@ CheckVisaStatus --> HandleNoVisaDecision : default`);
101
101
}` )
102
102
) ;
103
103
const mermaidState = new MermaidState ( databasedswitch ) ;
104
- expect ( mermaidState . sourceCode ( ) ) . toBe ( `CheckApplication : CheckApplication
104
+ expect ( mermaidState . sourceCode ( ) ) . toBe ( `CheckApplication : Check Application
105
105
CheckApplication : type = Switch State
106
106
CheckApplication : Condition type = data-based
107
107
CheckApplication --> StartApplication : \${ .applicants | .age >= 18 }
@@ -130,7 +130,7 @@ CheckApplication --> RejectApplication : default`);
130
130
}` )
131
131
) ;
132
132
const mermaidState = new MermaidState ( databasedswitch ) ;
133
- expect ( mermaidState . sourceCode ( ) ) . toBe ( `CheckApplication : CheckApplication
133
+ expect ( mermaidState . sourceCode ( ) ) . toBe ( `CheckApplication : Check Application
134
134
CheckApplication : type = Switch State
135
135
CheckApplication : Condition type = data-based
136
136
CheckApplication --> StartApplication : \${ .applicants | .age >= 18 }
@@ -160,7 +160,7 @@ CheckApplication --> StartApplication : default`);
160
160
}` )
161
161
) ;
162
162
const mermaidState = new MermaidState ( databasedswitch ) ;
163
- expect ( mermaidState . sourceCode ( ) ) . toBe ( `GreetPerson : GreetPerson
163
+ expect ( mermaidState . sourceCode ( ) ) . toBe ( `GreetPerson : Greet Person
164
164
GreetPerson : type = Operation State
165
165
GreetPerson : Num. of actions = 1
166
166
GreetPerson --> [*]` ) ;
@@ -191,7 +191,7 @@ GreetPerson --> [*]`);
191
191
}` )
192
192
) ;
193
193
const mermaidState = new MermaidState ( states ) ;
194
- expect ( mermaidState . sourceCode ( ) ) . toBe ( `SubmitJob : SubmitJob
194
+ expect ( mermaidState . sourceCode ( ) ) . toBe ( `SubmitJob : Submit Job
195
195
SubmitJob : type = Operation State
196
196
SubmitJob : Action mode = sequential
197
197
SubmitJob : Num. of actions = 1
@@ -208,7 +208,7 @@ SubmitJob --> WaitForCompletion`);
208
208
}` )
209
209
) ;
210
210
const mermaidState = new MermaidState ( states ) ;
211
- expect ( mermaidState . sourceCode ( ) ) . toBe ( `WaitForCompletion : WaitForCompletion
211
+ expect ( mermaidState . sourceCode ( ) ) . toBe ( `WaitForCompletion : Wait For Completion
212
212
WaitForCompletion : type = Sleep State
213
213
WaitForCompletion : Duration = PT5S
214
214
WaitForCompletion --> GetJobStatus` ) ;
@@ -241,7 +241,7 @@ WaitForCompletion --> GetJobStatus`);
241
241
}` )
242
242
) ;
243
243
const mermaidState = new MermaidState ( states , true ) ;
244
- expect ( mermaidState . sourceCode ( ) ) . toBe ( `ProvisionOrdersState : ProvisionOrdersState
244
+ expect ( mermaidState . sourceCode ( ) ) . toBe ( `ProvisionOrdersState : Provision Orders State
245
245
ProvisionOrdersState : type = Foreach State
246
246
ProvisionOrdersState : Input collection = \${ .orders }
247
247
ProvisionOrdersState : Num. of actions = 1
@@ -270,7 +270,7 @@ ProvisionOrdersState --> [*] : Produced event = [provisioningCompleteEvent]`);
270
270
}` )
271
271
) ;
272
272
const mermaidState = new MermaidState ( states , true ) ;
273
- expect ( mermaidState . sourceCode ( ) ) . toBe ( `CheckCredit : CheckCredit
273
+ expect ( mermaidState . sourceCode ( ) ) . toBe ( `CheckCredit : Check Credit
274
274
CheckCredit : type = Callback State
275
275
CheckCredit : Callback function = callCreditCheckMicroservice
276
276
CheckCredit : Callback event = CreditCheckCompletedEvent
@@ -287,12 +287,12 @@ CheckCredit --> EvaluateDecision`);
287
287
}` )
288
288
) ;
289
289
const mermaidState = new MermaidState ( states ) ;
290
- expect ( mermaidState . sourceCode ( ) ) . toBe ( `CheckCredit : CheckCredit
290
+ expect ( mermaidState . sourceCode ( ) ) . toBe ( `CheckCredit : Check Credit
291
291
CheckCredit : type = Callback State
292
292
CheckCredit --> EvaluateDecision` ) ;
293
293
} ) ;
294
294
295
- it ( `should convert white spaces with underscore to create the state key` , ( ) => {
295
+ it ( `should remove white spaces when creating the state key` , ( ) => {
296
296
const databasedswitch = new Specification . Databasedswitchstate (
297
297
JSON . parse ( `{
298
298
"type":"switch",
@@ -313,11 +313,40 @@ CheckCredit --> EvaluateDecision`);
313
313
}` )
314
314
) ;
315
315
const mermaidState = new MermaidState ( databasedswitch ) ;
316
- expect ( mermaidState . sourceCode ( ) ) . toBe ( `Check_Application : Check Application
317
- Check_Application : type = Switch State
318
- Check_Application : Condition type = data-based
319
- Check_Application --> Start_Application : \${ .applicants | .age >= 18 }
320
- Check_Application --> [*] : \${ .applicants | .age < 18 }
321
- Check_Application --> Start_Application : default` ) ;
316
+ expect ( mermaidState . sourceCode ( ) ) . toBe ( `CheckApplication : Check Application
317
+ CheckApplication : type = Switch State
318
+ CheckApplication : Condition type = data-based
319
+ CheckApplication --> StartApplication : \${ .applicants | .age >= 18 }
320
+ CheckApplication --> [*] : \${ .applicants | .age < 18 }
321
+ CheckApplication --> StartApplication : default` ) ;
322
+ } ) ;
323
+
324
+ it ( `should remove dashes when creating the state key` , ( ) => {
325
+ const databasedswitch = new Specification . Databasedswitchstate (
326
+ JSON . parse ( `{
327
+ "type":"switch",
328
+ "name":"check-application",
329
+ "dataConditions": [
330
+ {
331
+ "condition": "\${ .applicants | .age >= 18 }",
332
+ "transition": "start-application"
333
+ },
334
+ {
335
+ "condition": "\${ .applicants | .age < 18 }",
336
+ "end": true
337
+ }
338
+ ],
339
+ "defaultCondition": {
340
+ "transition": "start-application"
341
+ }
342
+ }` )
343
+ ) ;
344
+ const mermaidState = new MermaidState ( databasedswitch ) ;
345
+ expect ( mermaidState . sourceCode ( ) ) . toBe ( `CheckApplication : Check Application
346
+ CheckApplication : type = Switch State
347
+ CheckApplication : Condition type = data-based
348
+ CheckApplication --> StartApplication : \${ .applicants | .age >= 18 }
349
+ CheckApplication --> [*] : \${ .applicants | .age < 18 }
350
+ CheckApplication --> StartApplication : default` ) ;
322
351
} ) ;
323
352
} ) ;
0 commit comments