Skip to content

Commit

Permalink
test: add more tests for StyleComputer (#2835)
Browse files Browse the repository at this point in the history
Check the `computeStyle` methods for
  - font family only
  - pool/lane when isHorizontal not set
  • Loading branch information
tbouffard authored Aug 29, 2023
1 parent 792e4d1 commit 2e68fa0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/unit/component/mxgraph/renderer/StyleComputer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ describe('Style Computer', () => {
expect(computeStyle(shape)).toBe('intermediateThrowEvent;fontStyle=3');
});

it('compute style of shape with label including font family only', () => {
const shape = new Shape('id', newShapeBpmnElement(ShapeBpmnElementKind.TASK_SCRIPT), undefined, new Label(toFont({ name: 'Roboto' }), undefined));
expect(computeStyle(shape)).toBe('scriptTask;fontFamily=Roboto');
});

it('compute style of shape with label bounds', () => {
const shape = new Shape('id', newShapeBpmnElement(ShapeBpmnElementKind.CALL_ACTIVITY), undefined, new Label(undefined, new Bounds(40, 200, 80, 140)));
expect(computeStyle(shape)).toBe('callActivity;verticalAlign=top;align=center;labelWidth=81;labelPosition=ignore;verticalLabelPosition=middle');
Expand Down Expand Up @@ -386,6 +391,7 @@ describe('Style Computer', () => {
it.each([
['vertical', false, '1'],
['horizontal', true, '0'],
['no isHorizontal value for a', undefined, '1'],
])('%s pool references a Process', (title: string, isHorizontal: boolean, expected: string) => {
const shape = newShape(newShapeBpmnElement(ShapeBpmnElementKind.POOL), undefined, isHorizontal);
expect(computeStyle(shape)).toBe(`pool;horizontal=${expected}`);
Expand All @@ -396,6 +402,7 @@ describe('Style Computer', () => {
it.each([
['vertical', false, '1'],
['horizontal', true, '0'],
['no isHorizontal value for a', undefined, '1'],
])('%s lane', (title: string, isHorizontal: boolean, expected: string) => {
const shape = newShape(newShapeBpmnElement(ShapeBpmnElementKind.LANE), undefined, isHorizontal);
expect(computeStyle(shape)).toBe(`lane;horizontal=${expected}`);
Expand Down

0 comments on commit 2e68fa0

Please sign in to comment.