style(modeling): reformat test case

This commit is contained in:
Nico Rehwaldt 2017-03-21 09:01:42 +01:00
parent 2fd46ac294
commit 8d536f2cce
1 changed files with 220 additions and 241 deletions

View File

@ -75,7 +75,8 @@ describe('modeling - label layouting', function() {
describe('on segment move', function() {
it('label name not set -> move label to waypoints mid', inject(function(modeling, elementRegistry, connectionSegmentMove, dragging) {
it('label name not set -> move label to waypoints mid', inject(
function(modeling, elementRegistry, connectionSegmentMove, dragging) {
// given
var connection = elementRegistry.get('SequenceFlow_C'),
@ -94,7 +95,8 @@ describe('modeling - label layouting', function() {
// then
expect(connection.label.y - labelPosition.y).to.be.within(13, 16);
expect(connection.label.x - labelPosition.x).to.be.within(-87, -85);
}));
}
));
it('left - no relayout', inject(function(elementRegistry, connectionSegmentMove, dragging) {
@ -115,7 +117,8 @@ describe('modeling - label layouting', function() {
}));
it('left - remove bendpoint', inject(function(elementRegistry, connectionSegmentMove, dragging) {
it('left - remove bendpoint', inject(
function(elementRegistry, connectionSegmentMove, dragging) {
// given
var connection = elementRegistry.get('SequenceFlow_B'),
@ -130,10 +133,12 @@ describe('modeling - label layouting', function() {
// then
expectLabelMoved(connection, labelPosition, { x: -70, y: 24 });
}));
}
));
it('right - no relayout', inject(function(elementRegistry, connectionSegmentMove, dragging) {
it('right - no relayout', inject(
function(elementRegistry, connectionSegmentMove, dragging) {
// given
var connection = elementRegistry.get('SequenceFlow_B'),
@ -148,10 +153,12 @@ describe('modeling - label layouting', function() {
// then
expectLabelMoved(connection, labelPosition, { x: 30, y: 0 });
}));
}
));
it('right - remove bendpoint', inject(function(elementRegistry, connectionSegmentMove, dragging) {
it('right - remove bendpoint', inject(
function(elementRegistry, connectionSegmentMove, dragging) {
// given
var connection = elementRegistry.get('SequenceFlow_B'),
@ -166,7 +173,8 @@ describe('modeling - label layouting', function() {
// then
expectLabelMoved(connection, labelPosition, { x: 70, y: -16 });
}));
}
));
it('down', inject(function(elementRegistry, connectionSegmentMove, dragging) {
@ -188,7 +196,8 @@ describe('modeling - label layouting', function() {
}));
it('up - remove two bendpoints', inject(function(elementRegistry, connectionSegmentMove, dragging) {
it('up - remove two bendpoints', inject(
function(elementRegistry, connectionSegmentMove, dragging) {
// given
var connection = elementRegistry.get('SequenceFlow_C'),
@ -204,11 +213,13 @@ describe('modeling - label layouting', function() {
// then
expectLabelMoved(connection, labelPosition, { x: -39, y: -85 });
}));
}
));
// TODO(@janstuemmel): solve by connectionSegmentMove refactoring
it('up - remove two bendpoints - redundant waypoints', inject(function(elementRegistry, connectionSegmentMove, dragging, bendpointMove) {
it('up - remove two bendpoints - redundant waypoints', inject(
function(elementRegistry, connectionSegmentMove, dragging, bendpointMove) {
// given
var connection = elementRegistry.get('SequenceFlow_C');
@ -231,7 +242,8 @@ describe('modeling - label layouting', function() {
// then
expect(getLabelPosition(connection)).to.not.eql(labelPosition);
}));
}
));
});
@ -314,7 +326,8 @@ describe('modeling - label layouting', function() {
}));
it('move, label on bendpoint', inject(function(elementRegistry, bendpointMove, dragging, modeling) {
it('move, label on bendpoint', inject(
function(elementRegistry, bendpointMove, dragging, modeling) {
// given
var connection = elementRegistry.get('SequenceFlow_C');
@ -333,10 +346,12 @@ describe('modeling - label layouting', function() {
expect(Math.round(connection.label.x)).to.be.within(517, 519);
expect(Math.round(connection.label.y)).to.be.equal(507);
}));
}
));
it('remove bendpoint when label on segment', inject(function(elementRegistry, bendpointMove, dragging) {
it('remove bendpoint when label on segment', inject(
function(elementRegistry, bendpointMove, dragging) {
// given
var connection = elementRegistry.get('SequenceFlow_B');
@ -352,10 +367,12 @@ describe('modeling - label layouting', function() {
expect(Math.round(connection.label.x)).to.be.within(418, 421);
expect(Math.round(connection.label.y)).to.be.equal(191);
}));
}
));
it('add bendpoint, label on right segment', inject(function(elementRegistry, bendpointMove, dragging, canvas) {
it('add bendpoint, label on right segment', inject(
function(elementRegistry, bendpointMove, dragging, canvas) {
// given
var connection = elementRegistry.get('SequenceFlow_A');
@ -376,10 +393,12 @@ describe('modeling - label layouting', function() {
expect(Math.round(connection.label.x)).to.be.within(248, 251);
expect(Math.round(connection.label.y)).to.be.equal(152);
}));
}
));
it('add bendpoint, label on left segment', inject(function(elementRegistry, bendpointMove, dragging, canvas) {
it('add bendpoint, label on left segment', inject(
function(elementRegistry, bendpointMove, dragging, canvas) {
// given
var connection = elementRegistry.get('SequenceFlow_A');
@ -400,11 +419,12 @@ describe('modeling - label layouting', function() {
expect(Math.round(connection.label.x)).to.be.within(240, 242);
expect(Math.round(connection.label.y)).to.be.equal(148);
}));
}
));
it('remove bendpoint when label on bendpoint', inject(function(elementRegistry, bendpointMove, dragging, modeling) {
it('remove bendpoint when label on bendpoint', inject(
function(elementRegistry, bendpointMove, dragging, modeling) {
// given
var connection = elementRegistry.get('SequenceFlow_C');
@ -423,10 +443,12 @@ describe('modeling - label layouting', function() {
expect(Math.round(connection.label.x)).to.be.within(462, 465);
expect(Math.round(connection.label.y)).to.be.within(290, 293);
}));
}
));
it('add benpoint, label on segment, should not move', inject(function(elementRegistry, bendpointMove, canvas, dragging, modeling) {
it('add benpoint, label on segment, should not move', inject(
function(elementRegistry, bendpointMove, canvas, dragging, modeling) {
// given
var connection = elementRegistry.get('SequenceFlow_C');
@ -450,14 +472,16 @@ describe('modeling - label layouting', function() {
// then
expectLabelMoved(connection, position, { x: 0, y: 0 });
}));
}
));
});
describe('special cases', function() {
it('should behave properly, right after importing', inject(function(elementRegistry, connectionSegmentMove, dragging, modeling) {
it('should behave properly, right after importing', inject(
function(elementRegistry, connectionSegmentMove, dragging, modeling) {
// given
var connection = elementRegistry.get('SequenceFlow_C'),
@ -484,10 +508,12 @@ describe('modeling - label layouting', function() {
// then
expectLabelMoved(connection, labelPosition, { x: 20, y: 40 });
}));
}
));
it('should reposition on right segment', inject(function(elementRegistry, connectionSegmentMove, dragging) {
it('should reposition on right segment', inject(
function(elementRegistry, connectionSegmentMove, dragging) {
// given
var connection = elementRegistry.get('SequenceFlow_E'),
@ -504,55 +530,8 @@ describe('modeling - label layouting', function() {
expect(connection.label.y - labelPosition.y).to.be.within(-76, -70);
expect(connection.label.x - labelPosition.x).to.be.within(-54, -51);
}));
describe.skip('label out of bounds', function() {
it('should not move label that is out of bounds', inject(function(elementRegistry, connectionSegmentMove, dragging, modeling) {
// given
var connection = elementRegistry.get('SequenceFlow_C');
// move shape away
modeling.moveShape(connection.label, { x: 0, y: 140 });
var labelPosition = getLabelPosition(connection);
// when
connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 2);
dragging.move(canvasEvent({ x: 0, y: 30 }));
dragging.end();
// then
expectLabelMoved(connection, labelPosition, { x: 0, y: 0 });
}));
it('should not move label that is out of bounds in corner', inject(function(elementRegistry, connectionSegmentMove, dragging, modeling) {
// given
var connection = elementRegistry.get('SequenceFlow_C');
// move shape away
modeling.moveShape(connection.label, { x: 50, y: 0 });
var labelPosition = getLabelPosition(connection);
// when
connectionSegmentMove.start(canvasEvent({ x: 0, y: 0 }), connection, 2);
dragging.move(canvasEvent({ x: 0, y: 30 }));
dragging.end();
// then
expectLabelMoved(connection, labelPosition, { x: 0, y: 0 });
}));
});
}
));
});