Skip to content

Commit

Permalink
Introduce 'toBeReceiveTask' Jest extension
Browse files Browse the repository at this point in the history
  • Loading branch information
csouchet committed Oct 13, 2020
1 parent e502f3d commit 7cf201a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
16 changes: 15 additions & 1 deletion test/e2e/ExpectModelUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,19 @@ 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, toBeTask, toBeServiceTask, toBeUserTask } from './matchers';
import {
toBeCell,
withGeometry,
withFont,
toBeSequenceFlow,
toBeMessageFlow,
toBeAssociationFlow,
toBeShape,
toBeTask,
toBeServiceTask,
toBeUserTask,
toBeReceiveTask,
} from './matchers';

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
Expand All @@ -34,6 +46,7 @@ declare global {
toBeTask(modelElement: ExpectedShapeModelElement): R;
toBeServiceTask(modelElement: ExpectedShapeModelElement): R;
toBeUserTask(modelElement: ExpectedShapeModelElement): R;
toBeReceiveTask(modelElement: ExpectedShapeModelElement): R;
}
}
}
Expand All @@ -49,6 +62,7 @@ expect.extend({
toBeTask,
toBeServiceTask,
toBeUserTask,
toBeReceiveTask,
});

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, toBeTask, toBeServiceTask, toBeUserTask } from './toBeShape';
export { toBeShape, toBeTask, toBeServiceTask, toBeUserTask, toBeReceiveTask } 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 @@ -73,3 +73,7 @@ export function toBeServiceTask(this: MatcherContext, received: string, expected
export function toBeUserTask(this: MatcherContext, received: string, expected: ExpectedShapeModelElement): CustomMatcherResult {
return buildCellMatcher('toBeUserTask', this, received, { ...expected, kind: ShapeBpmnElementKind.TASK_USER }, 'Shape', buildExpectedCell);
}

export function toBeReceiveTask(this: MatcherContext, received: string, expected: ExpectedShapeModelElement): CustomMatcherResult {
return buildCellMatcher('toBeReceiveTask', this, received, { ...expected, kind: ShapeBpmnElementKind.TASK_RECEIVE }, 'Shape', buildExpectedCell);
}
24 changes: 8 additions & 16 deletions test/e2e/mxGraph.model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -812,57 +812,49 @@ describe('mxGraph model', () => {
});

// Receive Task: Non instantiating
expect('receive_task_non_instantiating_id').toBeShape({
kind: ShapeBpmnElementKind.TASK_RECEIVE,
expect('receive_task_non_instantiating_id').toBeReceiveTask({
label: 'Non-instantiating Receive Task',
isInstantiating: false,
parentId: 'participant_1_id',
});
expect('receive_task_non_instantiating_with_loop_id').toBeShape({
kind: ShapeBpmnElementKind.TASK_RECEIVE,
expect('receive_task_non_instantiating_with_loop_id').toBeReceiveTask({
label: 'Non-instantiating Receive Task With Loop',
isInstantiating: false,
markers: [ShapeBpmnMarkerKind.LOOP],
parentId: 'participant_1_id',
});
expect('receive_task_non_instantiating_with_sequential_multi_instance_id').toBeShape({
kind: ShapeBpmnElementKind.TASK_RECEIVE,
expect('receive_task_non_instantiating_with_sequential_multi_instance_id').toBeReceiveTask({
label: 'Non-instantiating Receive Task With Sequential Multi-instance',
isInstantiating: false,
markers: [ShapeBpmnMarkerKind.MULTI_INSTANCE_SEQUENTIAL],
parentId: 'participant_1_id',
});
expect('receive_task_non_instantiating_with_parallel_multi_instance_id').toBeShape({
kind: ShapeBpmnElementKind.TASK_RECEIVE,
expect('receive_task_non_instantiating_with_parallel_multi_instance_id').toBeReceiveTask({
label: 'Non-instantiating Receive Task With Parallel Multi-instance',
isInstantiating: false,
markers: [ShapeBpmnMarkerKind.MULTI_INSTANCE_PARALLEL],
parentId: 'participant_1_id',
});

// Receive Task: Instantiating
expect('receive_task_instantiating_id').toBeShape({
kind: ShapeBpmnElementKind.TASK_RECEIVE,
expect('receive_task_instantiating_id').toBeReceiveTask({
label: 'Instantiating Receive Task',
isInstantiating: true,
parentId: 'participant_1_id',
});
expect('receive_task_instantiating_with_loop_id').toBeShape({
kind: ShapeBpmnElementKind.TASK_RECEIVE,
expect('receive_task_instantiating_with_loop_id').toBeReceiveTask({
label: 'Instantiating Receive Task With Loop',
isInstantiating: true,
markers: [ShapeBpmnMarkerKind.LOOP],
parentId: 'participant_1_id',
});
expect('receive_task_instantiating_with_sequential_multi_instance_id').toBeShape({
kind: ShapeBpmnElementKind.TASK_RECEIVE,
expect('receive_task_instantiating_with_sequential_multi_instance_id').toBeReceiveTask({
label: 'Instantiating Receive Task With Sequential Multi-instance',
isInstantiating: true,
markers: [ShapeBpmnMarkerKind.MULTI_INSTANCE_SEQUENTIAL],
parentId: 'participant_1_id',
});
expect('receive_task_instantiating_with_parallel_multi_instance_id').toBeShape({
kind: ShapeBpmnElementKind.TASK_RECEIVE,
expect('receive_task_instantiating_with_parallel_multi_instance_id').toBeReceiveTask({
label: 'Instantiating Receive Task With Parallel Multi-instance',
isInstantiating: true,
markers: [ShapeBpmnMarkerKind.MULTI_INSTANCE_PARALLEL],
Expand Down

0 comments on commit 7cf201a

Please sign in to comment.