Skip to content

Commit

Permalink
Add unit tests for computeStyle
Browse files Browse the repository at this point in the history
  • Loading branch information
csouchet committed Oct 4, 2023
1 parent 3c2c5d5 commit a8383da
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/unit/component/mxgraph/renderer/StyleComputer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ import ShapeBpmnElement, {
ShapeBpmnActivity,
ShapeBpmnBoundaryEvent,
ShapeBpmnCallActivity,
ShapeBpmnIntermediateCatchEvent,
ShapeBpmnEvent,
ShapeBpmnEventBasedGateway,
ShapeBpmnStartEvent,
ShapeBpmnSubProcess,
ShapeBpmnIntermediateThrowEvent,
} from '@lib/model/bpmn/internal/shape/ShapeBpmnElement';

function toFont(font: ExpectedFont): Font {
Expand Down Expand Up @@ -95,6 +97,18 @@ function newShapeBpmnEvent(bpmnElementKind: BpmnEventKind, eventDefinitionKind:
return new ShapeBpmnEvent('id', 'name', bpmnElementKind, eventDefinitionKind, null);
}

function newShapeBpmnIntermediateCatchEvent(eventDefinitionKind: ShapeBpmnEventDefinitionKind, sourceIds: string[] = []): ShapeBpmnEvent {
const catchEvent = new ShapeBpmnIntermediateCatchEvent('id', 'name', eventDefinitionKind, null);
catchEvent.sourceIds = sourceIds;
return catchEvent;
}

function newShapeBpmnIntermediateThrowEvent(eventDefinitionKind: ShapeBpmnEventDefinitionKind, targetId?: string): ShapeBpmnEvent {
const throwEvent = new ShapeBpmnIntermediateThrowEvent('id', 'name', eventDefinitionKind, null);
throwEvent.targetId = targetId;
return throwEvent;
}

function newShapeBpmnBoundaryEvent(eventDefinitionKind: ShapeBpmnEventDefinitionKind, isInterrupting: boolean): ShapeBpmnBoundaryEvent {
return new ShapeBpmnBoundaryEvent('id', 'name', eventDefinitionKind, null, isInterrupting);
}
Expand Down Expand Up @@ -247,6 +261,21 @@ describe('Style Computer', () => {
expect(computeStyle(shape)).toBe('intermediateCatchEvent;bpmn.eventDefinitionKind=conditional;fontFamily=Ubuntu');
});

it('intermediate catch link with one source', () => {
const shape = newShape(newShapeBpmnIntermediateCatchEvent(ShapeBpmnEventDefinitionKind.LINK, ['source_id']));
expect(computeStyle(shape)).toBe('intermediateCatchEvent;bpmn.eventDefinitionKind=link;bpmn.linkEventSourceIds=source_id');
});

it('intermediate catch link with several sources', () => {
const shape = newShape(newShapeBpmnIntermediateCatchEvent(ShapeBpmnEventDefinitionKind.LINK, ['source_id_1', 'source_id_2']));
expect(computeStyle(shape)).toBe('intermediateCatchEvent;bpmn.eventDefinitionKind=link;bpmn.linkEventSourceIds=source_id_1,source_id_2');
});

it('intermediate throw link', () => {
const shape = newShape(newShapeBpmnIntermediateThrowEvent(ShapeBpmnEventDefinitionKind.LINK, 'target_id'));
expect(computeStyle(shape)).toBe('intermediateThrowEvent;bpmn.eventDefinitionKind=link;bpmn.linkEventTargetId=target_id');
});

it('start signal', () => {
const shape = newShape(newShapeBpmnEvent(ShapeBpmnElementKind.EVENT_START, ShapeBpmnEventDefinitionKind.SIGNAL), newLabel({ isBold: true }));
expect(computeStyle(shape)).toBe('startEvent;bpmn.eventDefinitionKind=signal;fontStyle=1');
Expand Down

0 comments on commit a8383da

Please sign in to comment.