diff --git a/test/unit/component/parser/json/BpmnJsonParser.event.boundary.test.ts b/test/unit/component/parser/json/BpmnJsonParser.event.boundary.test.ts index d6786739ec..25e582addc 100644 --- a/test/unit/component/parser/json/BpmnJsonParser.event.boundary.test.ts +++ b/test/unit/component/parser/json/BpmnJsonParser.event.boundary.test.ts @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import type { BuildDefinitionParameter } from '../../../helpers/JsonBuilder'; +import type { BuildDefinitionParameter, BuildEventDefinition } from '../../../helpers/JsonBuilder'; import { buildDefinitions, EventDefinitionOn } from '../../../helpers/JsonBuilder'; import { expectAsWarning, parseJsonAndExpectOnlyFlowNodes, parsingMessageCollector } from '../../../helpers/JsonTestUtils'; @@ -42,7 +42,7 @@ function testMustNotConvertBoundaryEvent(definitionParameter: BuildDefinitionPar } describe('for boundaryEvents', () => { - describe.each(eventDefinitionsParameters)(`for %s boundaryEvent`, (eventDefinitionKind: string, expectedEventDefinitionKind: ShapeBpmnEventDefinitionKind) => { + describe.each(eventDefinitionsParameters)(`for %s boundaryEvent`, (eventDefinitionKind: BuildEventDefinition, expectedEventDefinitionKind: ShapeBpmnEventDefinitionKind) => { if ( expectedEventDefinitionKind === ShapeBpmnEventDefinitionKind.NONE || expectedEventDefinitionKind === ShapeBpmnEventDefinitionKind.LINK || @@ -104,7 +104,7 @@ describe('for boundaryEvents', () => { bpmnElementKind: ShapeBpmnElementKind.EVENT_BOUNDARY, bpmnElementName: undefined, eventDefinitionKind: expectedEventDefinitionKind, - isInterrupting: true, + isInterrupting, }, ); }); @@ -127,7 +127,7 @@ describe('for boundaryEvents', () => { }); }); - it(`should NOT convert, when 'boundaryEvent' is ${isInterruptingTitle} & attached to no existing activity, ${titleForEventDefinitionIsAttributeOf}`, () => { + it(`should NOT convert, when 'boundaryEvent' is ${isInterruptingTitle} & attached to unexisting activity, ${titleForEventDefinitionIsAttributeOf}`, () => { testMustNotConvertBoundaryEvent( { process: { diff --git a/test/unit/component/parser/json/BpmnJsonParser.event.none.test.ts b/test/unit/component/parser/json/BpmnJsonParser.event.none.test.ts index 6934feb76b..501e58109c 100644 --- a/test/unit/component/parser/json/BpmnJsonParser.event.none.test.ts +++ b/test/unit/component/parser/json/BpmnJsonParser.event.none.test.ts @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import type { OtherBuildEventKind } from '../../../helpers/JsonBuilder'; +import type { BuildEventDefinition, OtherBuildEventKind } from '../../../helpers/JsonBuilder'; import { verifyShape } from '../../../helpers/bpmn-model-expect'; import { buildDefinitions, EventDefinitionOn } from '../../../helpers/JsonBuilder'; @@ -25,14 +25,14 @@ import { ShapeBpmnElementKind, ShapeBpmnEventDefinitionKind } from '@lib/model/b // None intermediateCatchEvent not supported in BPMN specification describe.each([ - [ShapeBpmnElementKind.EVENT_START, ['message', 'timer', 'conditional', 'signal']], - [ShapeBpmnElementKind.EVENT_END, ['message', 'error', 'escalation', 'cancel', 'compensate', 'signal', 'terminate']], - [ShapeBpmnElementKind.EVENT_INTERMEDIATE_THROW, ['message', 'escalation', 'compensate', 'link', 'signal']], -])('for none %s', (expectedShapeBpmnElementKind: ShapeBpmnElementKind, allDefinitionKinds: string[]) => { + [ShapeBpmnElementKind.EVENT_START, ['message', 'timer', 'conditional', 'signal'] as BuildEventDefinition[]], + [ShapeBpmnElementKind.EVENT_END, ['message', 'error', 'escalation', 'cancel', 'compensate', 'signal', 'terminate'] as BuildEventDefinition[]], + [ShapeBpmnElementKind.EVENT_INTERMEDIATE_THROW, ['message', 'escalation', 'compensate', 'link', 'signal'] as BuildEventDefinition[]], +])('for none %s', (expectedShapeBpmnElementKind: ShapeBpmnElementKind, allDefinitionKinds: BuildEventDefinition[]) => { executeEventCommonTests( { bpmnKind: expectedShapeBpmnElementKind as OtherBuildEventKind | 'startEvent', - eventDefinitionParameter: { eventDefinitionKind: 'none', eventDefinitionOn: EventDefinitionOn.NONE }, + eventDefinitionParameter: { eventDefinitionOn: EventDefinitionOn.NONE }, }, { bpmnElementKind: expectedShapeBpmnElementKind, diff --git a/test/unit/component/parser/json/BpmnJsonParser.event.with.event.definition.test.ts b/test/unit/component/parser/json/BpmnJsonParser.event.with.event.definition.test.ts index db5f7ff6d3..5e43ea4e66 100644 --- a/test/unit/component/parser/json/BpmnJsonParser.event.with.event.definition.test.ts +++ b/test/unit/component/parser/json/BpmnJsonParser.event.with.event.definition.test.ts @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import type { OtherBuildEventKind } from '../../../helpers/JsonBuilder'; +import type { BuildEventDefinition, OtherBuildEventKind } from '../../../helpers/JsonBuilder'; import type { TEventDefinition } from '@lib/model/bpmn/json/baseElement/rootElement/eventDefinition'; import { EventDefinitionOn } from '../../../helpers/JsonBuilder'; @@ -27,7 +27,7 @@ describe.each([ShapeBpmnElementKind.EVENT_START, ShapeBpmnElementKind.EVENT_END, (expectedShapeBpmnElementKind: ShapeBpmnElementKind) => { describe.each(eventDefinitionsParameters)( `for %s ${expectedShapeBpmnElementKind}`, - (eventDefinitionKind: string, expectedEventDefinitionKind: ShapeBpmnEventDefinitionKind) => { + (eventDefinitionKind: BuildEventDefinition, expectedEventDefinitionKind: ShapeBpmnEventDefinitionKind) => { if ( (expectedShapeBpmnElementKind === ShapeBpmnElementKind.EVENT_START && (expectedEventDefinitionKind === ShapeBpmnEventDefinitionKind.ERROR || diff --git a/test/unit/helpers/JsonBuilder.ts b/test/unit/helpers/JsonBuilder.ts index ab4bb2a98e..c415dc8bcd 100644 --- a/test/unit/helpers/JsonBuilder.ts +++ b/test/unit/helpers/JsonBuilder.ts @@ -69,8 +69,9 @@ type BuildBoundaryEventParameter = { attachedToRef: string; } & BuildInterruptingEventParameter; +export type BuildEventDefinition = 'message' | 'signal' | 'timer' | 'error' | 'escalation' | 'cancel' | 'compensate' | 'conditional' | 'link' | 'terminate'; export type BuildEventDefinitionParameter = { - eventDefinitionKind?: string; + eventDefinitionKind?: BuildEventDefinition; eventDefinitionOn: EventDefinitionOn; eventDefinition?: BPMNEventDefinition; withDifferentDefinition?: boolean; @@ -486,9 +487,8 @@ function addEventDefinitions( { eventDefinitionKind, eventDefinition = '', withDifferentDefinition = false }: BuildEventDefinitionParameter, differentEventDefinition: TEventDefinition | string = '', ): void { - if (eventDefinitionKind !== 'none') { - event[`${eventDefinitionKind}EventDefinition`] = eventDefinition; - } + event[`${eventDefinitionKind}EventDefinition` as keyof BPMNTEvent] = eventDefinition; + if (withDifferentDefinition) { const otherEventDefinition = eventDefinitionKind === 'signal' ? 'message' : 'signal'; event[`${otherEventDefinition}EventDefinition`] = differentEventDefinition; diff --git a/test/unit/helpers/TestUtils.BpmnJsonParser.event.ts b/test/unit/helpers/TestUtils.BpmnJsonParser.event.ts index 517a3d9a16..0584bc9479 100644 --- a/test/unit/helpers/TestUtils.BpmnJsonParser.event.ts +++ b/test/unit/helpers/TestUtils.BpmnJsonParser.event.ts @@ -15,7 +15,7 @@ limitations under the License. */ import type { ExpectedBoundaryEventShape, ExpectedEventShape, ExpectedShape } from './bpmn-model-expect'; -import type { BuildEventsParameter } from './JsonBuilder'; +import type { BuildEventDefinition, BuildEventsParameter } from './JsonBuilder'; import { verifyShape } from './bpmn-model-expect'; import { buildDefinitions, EventDefinitionOn } from './JsonBuilder'; @@ -214,7 +214,7 @@ export function executeEventCommonTests(buildEventParameter: BuildEventsParamete } } -export const eventDefinitionsParameters: [string, ShapeBpmnEventDefinitionKind][] = [ +export const eventDefinitionsParameters: [BuildEventDefinition, ShapeBpmnEventDefinitionKind][] = [ ['message', ShapeBpmnEventDefinitionKind.MESSAGE], ['timer', ShapeBpmnEventDefinitionKind.TIMER], ['terminate', ShapeBpmnEventDefinitionKind.TERMINATE],