Skip to content

Commit

Permalink
test: add unit tests for resize constraints to cover all directions i…
Browse files Browse the repository at this point in the history
…nc. vertical lanes
  • Loading branch information
abdul99ahad authored and nikku committed Sep 9, 2024
1 parent 7a137cc commit cd6bcad
Showing 1 changed file with 97 additions and 0 deletions.
97 changes: 97 additions & 0 deletions test/spec/features/modeling/behavior/ResizeBehaviorSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,66 @@ describe('features/modeling - resize behavior', function() {
})
);


it('should snap to nested child lanes from <ne>', inject(
function(dragging, elementRegistry, resize) {

// given
var lane = elementRegistry.get('Lane_A');

// when
resize.activate(canvasEvent({ x: 0, y: 0 }), lane, 'ne');

dragging.move(canvasEvent({ x: -500, y: 500 }));

dragging.end();

// then
expect(lane.width).to.equal(330);
expect(lane.height).to.equal(105);
})
);


it('should snap to nested child lanes from <sw>', inject(
function(dragging, elementRegistry, resize) {

// given
var lane = elementRegistry.get('Lane_A');

// when
resize.activate(canvasEvent({ x: 0, y: 0 }), lane, 'sw');

dragging.move(canvasEvent({ x: 500, y: -500 }));

dragging.end();

// then
expect(lane.width).to.equal(563);
expect(lane.height).to.equal(60);
})
);


it('should snap to other sibling lanes child participants from <nw>', inject(
function(dragging, elementRegistry, resize) {

// given
var lane = elementRegistry.get('Lane_B_0');

// when
resize.activate(canvasEvent({ x: 0, y: 0 }), lane, 'nw');

dragging.move(canvasEvent({ x: 500, y: 500 }));

dragging.end();

// then
expect(lane.width).to.equal(563);
expect(lane.height).to.equal(60);
})
);

});


Expand Down Expand Up @@ -893,6 +953,43 @@ describe('modeling/behavior - resize behavior - utilities', function() {

}));

it('left lane (E)', inject(function(elementRegistry) {

// given
var resizeShape = elementRegistry.get('Vertical_Lane_A'),
nestedLaneShape = elementRegistry.get('Nested_Vertical_Lane_B');

// when
var sizeConstraints = getParticipantResizeConstraints(resizeShape, 'e');

// then
expect(sizeConstraints).to.eql({
min: {
right: nestedLaneShape.x + VERTICAL_LANE_MIN_WIDTH
},
max: {}
});

}));

it('nested left lane (E)', inject(function(elementRegistry) {

// given
var resizeShape = elementRegistry.get('Nested_Vertical_Lane_A');

// when
var sizeConstraints = getParticipantResizeConstraints(resizeShape, 'e');

// then
expect(sizeConstraints).to.eql({
min: {
right: resizeShape.x + VERTICAL_LANE_MIN_WIDTH
},
max: {}
});

}));


it('resize participant (W)', inject(function(elementRegistry) {

Expand Down

0 comments on commit cd6bcad

Please sign in to comment.