Skip to content

Commit

Permalink
[TEST] Introduce 'toBeTask' Jest extension (#755)
Browse files Browse the repository at this point in the history
  • Loading branch information
csouchet authored Oct 14, 2020
1 parent 8a35e75 commit 2e43a72
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
4 changes: 3 additions & 1 deletion test/e2e/ExpectModelUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { FlowKind } from '../../src/model/bpmn/internal/edge/FlowKind';
import { MessageVisibleKind } from '../../src/model/bpmn/internal/edge/MessageVisibleKind';
import { SequenceFlowKind } from '../../src/model/bpmn/internal/edge/SequenceFlowKind';
import BpmnVisualization from '../../src/component/BpmnVisualization';
import { toBeCell, withGeometry, withFont, toBeSequenceFlow, toBeMessageFlow, toBeAssociationFlow, toBeShape, toBeCallActivity } from './matchers';
import { toBeCell, withGeometry, withFont, toBeSequenceFlow, toBeMessageFlow, toBeAssociationFlow, toBeShape, toBeCallActivity, toBeTask } from './matchers';

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
Expand All @@ -32,6 +32,7 @@ declare global {
toBeAssociationFlow(modelElement: ExpectedEdgeModelElement): R;
toBeShape(modelElement: ExpectedShapeModelElement): R;
toBeCallActivity(modelElement: ExpectedShapeModelElement): R;
toBeTask(modelElement: ExpectedShapeModelElement): R;
}
}
}
Expand All @@ -45,6 +46,7 @@ expect.extend({
toBeAssociationFlow,
toBeShape,
toBeCallActivity,
toBeTask,
});

export interface ExpectedFont {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/matchers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/
export { toBeSequenceFlow, toBeMessageFlow, toBeAssociationFlow } from './toBeEdge';
export { toBeShape, toBeCallActivity } from './toBeShape';
export { toBeShape, toBeCallActivity, toBeTask } from './toBeShape';
export { toBeCell } from './toBeCell';
export { withGeometry } from './withGeometry';
export { withFont } from './withFont';
4 changes: 4 additions & 0 deletions test/e2e/matchers/toBeShape/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,7 @@ export function toBeShape(this: MatcherContext, received: string, expected: Expe
export function toBeCallActivity(this: MatcherContext, received: string, expected: ExpectedShapeModelElement): CustomMatcherResult {
return buildCellMatcher('toBeCallActivity', this, received, { ...expected, kind: ShapeBpmnElementKind.CALL_ACTIVITY }, 'Shape', buildExpectedCell);
}

export function toBeTask(this: MatcherContext, received: string, expected: ExpectedShapeModelElement): CustomMatcherResult {
return buildCellMatcher('toBeTask', this, received, { ...expected, kind: ShapeBpmnElementKind.TASK }, 'Shape', buildExpectedCell);
}
14 changes: 5 additions & 9 deletions test/e2e/mxGraph.model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -730,27 +730,23 @@ describe('mxGraph model', () => {

// activity
// Task
expect('task_id').toBeShape({ kind: ShapeBpmnElementKind.TASK, label: 'Task', parentId: 'participant_1_id' });
expect('task_with_loop_id').toBeShape({
kind: ShapeBpmnElementKind.TASK,
expect('task_id').toBeTask({ label: 'Task', parentId: 'participant_1_id' });
expect('task_with_loop_id').toBeTask({
label: 'Task With Loop',
markers: [ShapeBpmnMarkerKind.LOOP],
parentId: 'participant_1_id',
});
expect('task_with_sequential_multi_instance_id').toBeShape({
kind: ShapeBpmnElementKind.TASK,
expect('task_with_sequential_multi_instance_id').toBeTask({
label: 'Task With Sequential Multi-instance',
markers: [ShapeBpmnMarkerKind.MULTI_INSTANCE_SEQUENTIAL],
parentId: 'participant_1_id',
});
expect('task_with_parallel_multi_instance_id').toBeShape({
kind: ShapeBpmnElementKind.TASK,
expect('task_with_parallel_multi_instance_id').toBeTask({
label: 'Task With Parallel Multi-instance',
markers: [ShapeBpmnMarkerKind.MULTI_INSTANCE_PARALLEL],
parentId: 'participant_1_id',
});
expect('task_with_flows_id').toBeShape({
kind: ShapeBpmnElementKind.TASK,
expect('task_with_flows_id').toBeTask({
font: {
isBold: false,
isItalic: false,
Expand Down

0 comments on commit 2e43a72

Please sign in to comment.