@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17- import { ShapeBpmnElementKind , ShapeUtil } from '@lib/model/bpmn/internal' ;
17+ import { FlowKind , ShapeBpmnElementKind , ShapeUtil } from '@lib/model/bpmn/internal' ;
1818
1919describe ( 'ShapeUtil' , ( ) => {
2020 it ( 'top level bpmn event kinds' , ( ) => {
@@ -29,6 +29,20 @@ describe('ShapeUtil', () => {
2929 expect ( tasks ) . toContain ( ShapeBpmnElementKind . TASK_USER ) ;
3030 } ) ;
3131
32+ it ( 'flow node kinds' , ( ) => {
33+ const flowNodeKinds = ShapeUtil . flowNodeKinds ( ) ;
34+ expect ( flowNodeKinds ) . toContain ( ShapeBpmnElementKind . TASK ) ;
35+ expect ( flowNodeKinds ) . toContain ( ShapeBpmnElementKind . EVENT_INTERMEDIATE_CATCH ) ;
36+ expect ( flowNodeKinds ) . toContain ( ShapeBpmnElementKind . GROUP ) ; // artifact should not be included
37+ expect ( flowNodeKinds ) . not . toContain ( ShapeBpmnElementKind . POOL ) ;
38+ } ) ;
39+
40+ it ( 'artifact kinds' , ( ) => {
41+ const artifacts = ShapeUtil . artifactKinds ( ) ;
42+ expect ( artifacts ) . toContain ( ShapeBpmnElementKind . GROUP ) ;
43+ expect ( artifacts ) . toContain ( ShapeBpmnElementKind . TEXT_ANNOTATION ) ;
44+ } ) ;
45+
3246 describe ( 'Is pool or lane?' , ( ) => {
3347 it . each ( [
3448 [ ShapeBpmnElementKind . CALL_ACTIVITY ] ,
@@ -46,10 +60,51 @@ describe('ShapeUtil', () => {
4660 } ) ;
4761 } ) ;
4862
63+ describe ( 'isArtifact' , ( ) => {
64+ test . each `
65+ kind | expected
66+ ${ ShapeBpmnElementKind . EVENT_END } | ${ false }
67+ ${ ShapeBpmnElementKind . GATEWAY_PARALLEL } | ${ false }
68+ ${ ShapeBpmnElementKind . TASK } | ${ false }
69+ ${ ShapeBpmnElementKind . SUB_PROCESS } | ${ false }
70+ ${ ShapeBpmnElementKind . CALL_ACTIVITY } | ${ false }
71+ ${ ShapeBpmnElementKind . POOL } | ${ false }
72+ ${ ShapeBpmnElementKind . LANE } | ${ false }
73+ ${ ShapeBpmnElementKind . GROUP } | ${ true }
74+ ${ ShapeBpmnElementKind . TEXT_ANNOTATION } | ${ true }
75+ ${ FlowKind . MESSAGE_FLOW } | ${ false }
76+ ${ 'unknown' } | ${ false }
77+ ${ 'receiveTask' } | ${ false }
78+ ` ( '$kind isArtifact? $expected' , ( { kind, expected } : Record < string , unknown > ) => {
79+ expect ( ShapeUtil . isArtifact ( kind as string ) ) . toBe ( expected ) ;
80+ } ) ;
81+ } ) ;
82+
83+ describe ( 'isFlowNode' , ( ) => {
84+ test . each `
85+ kind | expected
86+ ${ ShapeBpmnElementKind . EVENT_END } | ${ true }
87+ ${ ShapeBpmnElementKind . GATEWAY_PARALLEL } | ${ true }
88+ ${ ShapeBpmnElementKind . TASK } | ${ true }
89+ ${ ShapeBpmnElementKind . SUB_PROCESS } | ${ true }
90+ ${ ShapeBpmnElementKind . CALL_ACTIVITY } | ${ true }
91+ ${ ShapeBpmnElementKind . POOL } | ${ false }
92+ ${ ShapeBpmnElementKind . LANE } | ${ false }
93+ ${ ShapeBpmnElementKind . GROUP } | ${ true }
94+ ${ ShapeBpmnElementKind . TEXT_ANNOTATION } | ${ true }
95+ ${ FlowKind . MESSAGE_FLOW } | ${ false }
96+ ${ 'unknown' } | ${ false }
97+ ${ 'receiveTask' } | ${ true }
98+ ` ( '$kind isFlowNode? $expected' , ( { kind, expected } : Record < string , unknown > ) => {
99+ expect ( ShapeUtil . isFlowNode ( kind as string ) ) . toBe ( expected ) ;
100+ } ) ;
101+ } ) ;
102+
49103 describe ( 'Reference kinds cannot be modified' , ( ) => {
50104 it . each `
51105 kind | kindsFunction
52106 ${ 'activities' } | ${ ( ) => ShapeUtil . activityKinds ( ) }
107+ ${ 'artifacts' } | ${ ( ) => ShapeUtil . artifactKinds ( ) }
53108 ${ 'events' } | ${ ( ) => ShapeUtil . eventKinds ( ) }
54109 ${ 'flow nodes' } | ${ ( ) => ShapeUtil . flowNodeKinds ( ) }
55110 ${ 'gateways' } | ${ ( ) => ShapeUtil . gatewayKinds ( ) }
0 commit comments