File tree Expand file tree Collapse file tree 2 files changed +34
-5
lines changed Expand file tree Collapse file tree 2 files changed +34
-5
lines changed Original file line number Diff line number Diff line change 1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
1515 */
16- import { Specification } from '../definitions' ;
17- import { isObject } from '../utils' ;
16+ import { Specification } from '../definitions' ;
17+ import { isObject } from '../utils' ;
1818
1919export class MermaidState {
2020 constructor (
@@ -144,7 +144,7 @@ export class MermaidState {
144144 if ( isObject ( this . state . end ) ) {
145145 const end = this . state . end as Specification . End ;
146146
147- if ( end . produceEvents ! . length > 0 ) {
147+ if ( end . produceEvents ) {
148148 transitionLabel = 'Produced event = [' + end . produceEvents ! . map ( ( pe ) => pe . eventRef ) . join ( ',' ) + ']' ;
149149 }
150150 }
Original file line number Diff line number Diff line change @@ -109,9 +109,9 @@ CheckApplication --> RejectApplication : \${ .applicants | .age < 18 }
109109CheckApplication --> RejectApplication : default` ) ;
110110 } ) ;
111111
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 ' , ( ) => {
113113 const databasedswitch = new Specification . Databasedswitchstate (
114- JSON . parse ( `{
114+ JSON . parse ( `{
115115 "type":"switch",
116116 "name":"CheckApplication",
117117 "dataConditions": [
@@ -138,6 +138,35 @@ CheckApplication --> [*] : \${ .applicants | .age < 18 }
138138CheckApplication --> StartApplication : default` ) ;
139139 } ) ;
140140
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+
141170 it ( 'should create source code for operation state' , ( ) => {
142171 const states = new Specification . Operationstate (
143172 JSON . parse ( `{
You can’t perform that action at this time.
0 commit comments