From a5ed6aa9dbea6f3829bf1e1ded541176156d108c Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Fri, 28 Nov 2014 13:19:57 +0100 Subject: [PATCH] test(modeling/move): add label move undo tests --- test/spec/features/modeling/MoveShapeSpec.js | 108 +++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/test/spec/features/modeling/MoveShapeSpec.js b/test/spec/features/modeling/MoveShapeSpec.js index 419d1582..04dcb964 100644 --- a/test/spec/features/modeling/MoveShapeSpec.js +++ b/test/spec/features/modeling/MoveShapeSpec.js @@ -254,6 +254,114 @@ describe('features/modeling - move shape', function() { expect(flowLabel.y).toBe(labelPosition.y - 80); })); + + describe('undo', function() { + + it('should undo label with shape', inject(function(elementRegistry, modeling, commandStack) { + + // given + var startEventElement = elementRegistry.get('StartEvent_1'), + startEvent = startEventElement.businessObject; + + var label = startEventElement.label; + + var labelPosition = { + x: label.x, + y: label.y + }; + + modeling.moveShapes([ startEventElement ], { x: 40, y: -80 }); + + // when + commandStack.undo(); + + // then + expect(label.x).toBe(labelPosition.x); + expect(label.y).toBe(labelPosition.y); + })); + + + it('should move label with connection', inject(function(elementRegistry, modeling, commandStack) { + + // given + var startEventElement = elementRegistry.get('StartEvent_2'), + startEvent = startEventElement.businessObject, + subProcessElement = elementRegistry.get('SubProcess_1'), + subProcess = startEventElement.businessObject, + flowLabel = elementRegistry.get('SequenceFlow_3_label'); + + var labelPosition = { + x: flowLabel.x, + y: flowLabel.y + }; + + modeling.moveShapes([ startEventElement, subProcessElement ], { x: 40, y: -80 }); + + // when + commandStack.undo(); + + // then + expect(flowLabel.x).toBe(labelPosition.x); + expect(flowLabel.y).toBe(labelPosition.y); + })); + + }); + + + describe('redo', function() { + + it('should redo move label with shape', inject(function(elementRegistry, modeling, commandStack) { + + // given + var startEventElement = elementRegistry.get('StartEvent_1'), + startEvent = startEventElement.businessObject; + + var label = startEventElement.label; + + var labelPosition = { + x: label.x, + y: label.y + }; + + modeling.moveShapes([ startEventElement ], { x: 40, y: -80 }); + commandStack.undo(); + + // when + commandStack.redo(); + + // then + expect(label.x).toBe(labelPosition.x + 40); + expect(label.y).toBe(labelPosition.y - 80); + })); + + + it('should redo move label with connection', inject(function(elementRegistry, modeling, commandStack) { + + // given + var startEventElement = elementRegistry.get('StartEvent_2'), + startEvent = startEventElement.businessObject, + subProcessElement = elementRegistry.get('SubProcess_1'), + subProcess = startEventElement.businessObject, + flowLabel = elementRegistry.get('SequenceFlow_3_label'); + + var labelPosition = { + x: flowLabel.x, + y: flowLabel.y + }; + + modeling.moveShapes([ startEventElement, subProcessElement ], { x: 40, y: -80 }); + commandStack.undo(); + + // when + commandStack.redo(); + + // then + expect(flowLabel.x).toBe(labelPosition.x + 40); + expect(flowLabel.y).toBe(labelPosition.y - 80); + })); + + }); + }); });