File tree 2 files changed +34
-5
lines changed
2 files changed +34
-5
lines changed Original file line number Diff line number Diff line change 13
13
* See the License for the specific language governing permissions and
14
14
* limitations under the License.
15
15
*/
16
- import { Specification } from '../definitions' ;
17
- import { isObject } from '../utils' ;
16
+ import { Specification } from '../definitions' ;
17
+ import { isObject } from '../utils' ;
18
18
19
19
export class MermaidState {
20
20
constructor (
@@ -144,7 +144,7 @@ export class MermaidState {
144
144
if ( isObject ( this . state . end ) ) {
145
145
const end = this . state . end as Specification . End ;
146
146
147
- if ( end . produceEvents ! . length > 0 ) {
147
+ if ( end . produceEvents ) {
148
148
transitionLabel = 'Produced event = [' + end . produceEvents ! . map ( ( pe ) => pe . eventRef ) . join ( ',' ) + ']' ;
149
149
}
150
150
}
Original file line number Diff line number Diff line change @@ -109,9 +109,9 @@ CheckApplication --> RejectApplication : \${ .applicants | .age < 18 }
109
109
CheckApplication --> RejectApplication : default` ) ;
110
110
} ) ;
111
111
112
- it ( 'should create source code for data-based state with end condition ' , ( ) => {
112
+ it ( 'should create source code for data-based state with end = true ' , ( ) => {
113
113
const databasedswitch = new Specification . Databasedswitchstate (
114
- JSON . parse ( `{
114
+ JSON . parse ( `{
115
115
"type":"switch",
116
116
"name":"CheckApplication",
117
117
"dataConditions": [
@@ -138,6 +138,35 @@ CheckApplication --> [*] : \${ .applicants | .age < 18 }
138
138
CheckApplication --> StartApplication : default` ) ;
139
139
} ) ;
140
140
141
+
142
+ it ( 'should create source code for operation state with end.terminate = true ' , ( ) => {
143
+ const databasedswitch = new Specification . Databasedswitchstate (
144
+ JSON . parse ( `{
145
+ "name": "GreetPerson",
146
+ "type": "operation",
147
+ "actions": [
148
+ {
149
+ "name": "greetAction",
150
+ "functionRef": {
151
+ "refName": "greetFunction",
152
+ "arguments": {
153
+ "message": "$.greeting $.name"
154
+ }
155
+ }
156
+ }
157
+ ],
158
+ "end": {
159
+ "terminate": true
160
+ }
161
+ }` )
162
+ ) ;
163
+ const mermaidState = new MermaidState ( databasedswitch ) ;
164
+ expect ( mermaidState . sourceCode ( ) ) . toBe ( `GreetPerson : GreetPerson
165
+ GreetPerson : type = Operation State
166
+ GreetPerson : Num. of actions = 1
167
+ GreetPerson --> [*]` ) ;
168
+ } ) ;
169
+
141
170
it ( 'should create source code for operation state' , ( ) => {
142
171
const states = new Specification . Operationstate (
143
172
JSON . parse ( `{
You can’t perform that action at this time.
0 commit comments