Skip to content

Commit

Permalink
chore(project): coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme authored and merge-me[bot] committed Oct 18, 2018
1 parent a6ebfd8 commit 372e439
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 17 deletions.
6 changes: 3 additions & 3 deletions lib/features/modeling/cmd/ReplaceShapeHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ ReplaceShapeHandler.prototype.preExecute = function(context) {
y: newData.y
};

newShape = context.newShape = (
context.newShape || self.createShape(newData, position, oldShape.parent, hints)
);
newShape = context.newShape =
context.newShape ||
self.createShape(newData, position, oldShape.parent, hints);


// (2) update the host
Expand Down
86 changes: 72 additions & 14 deletions test/spec/features/auto-resize/AutoResizeSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ describe('features/auto-resize', function() {
]
}));


beforeEach(inject(function(elementFactory, canvas) {
rootShape = elementFactory.createRoot({
id: 'root'
Expand All @@ -363,16 +362,20 @@ describe('features/auto-resize', function() {

collapsedShape = elementFactory.createShape({
id: 'collapsedShape',
x: 110, y: 110, width: 200, height: 200,
x: 110,
y: 110,
width: 200,
height: 200,
collapsed: true
});

canvas.addShape(collapsedShape, rootShape);

}));


it('should resize element which is expanded',
inject(function(elementFactory, canvas, modeling, autoResize) {

// given
var autoResizeSpy = sinon.spy(autoResize, '_expand');

Expand All @@ -388,28 +391,50 @@ describe('features/auto-resize', function() {
modeling.toggleCollapse(collapsedShape);

// then
expect(collapsedShape).to.have.bounds({ x: 110, y: 110, width: 420, height: 420 });
expect(hiddenContainedChild).to.have.bounds({ x: 120, y: 120, width: 400, height: 400 });
expect(collapsedShape).to.have.bounds({
x: 110,
y: 110,
width: 420,
height: 420
});

expect(hiddenContainedChild).to.have.bounds({
x: 120,
y: 120,
width: 400,
height: 400
});

expect(autoResizeSpy).to.be.called;
})
);


it('should resize element which is expanded even if it has no children',
inject(function(modeling, autoResize) {

// given
var autoResizeSpy = sinon.spy(autoResize, '_expand');

// when
modeling.toggleCollapse(collapsedShape);

// then
expect(collapsedShape).to.have.bounds({ x: 110, y: 110, width: 200, height: 200 });
expect(collapsedShape).to.have.bounds({
x: 110,
y: 110,
width: 200,
height: 200
});

expect(autoResizeSpy).to.be.called;
})
);


it('should not resize an expanded element which is collapsed',
inject(function(elementFactory, canvas, modeling, autoResize) {

// given
var autoResizeSpy = sinon.spy(autoResize, '_expand');

Expand All @@ -425,20 +450,30 @@ describe('features/auto-resize', function() {
modeling.toggleCollapse(expandedShape);

// then
expect(collapsedShape).to.have.bounds({ x: 110, y: 110, width: 200, height: 200 });
expect(collapsedShape).to.have.bounds({
x: 110,
y: 110,
width: 200,
height: 200
});

expect(autoResizeSpy).to.not.be.called;
})
);

});


describe('as a child of another element', function() {

beforeEach(inject(function(elementFactory, canvas) {

parentShape = elementFactory.createShape({
id: 'parentShape',
x: 110, y: 110, width: 200, height: 200
x: 110,
y: 110,
width: 200,
height: 200
});

canvas.addShape(parentShape, rootShape);
Expand All @@ -458,20 +493,33 @@ describe('features/auto-resize', function() {
});

canvas.addShape(hiddenContainedChild, collapsedShape);

}));


it('should resize also the parent element',
inject(function(modeling, autoResize) {

// given
var autoResizeSpy = sinon.spy(autoResize, '_expand');

// when
modeling.toggleCollapse(collapsedShape);

// then
expect(collapsedShape).to.have.bounds({ x: 120, y: 120, width: 420, height: 420 });
expect(parentShape).to.have.bounds({ x: 110, y: 110, width: 440, height: 440 });
expect(collapsedShape).to.have.bounds({
x: 120,
y: 120,
width: 420,
height: 420
});

expect(parentShape).to.have.bounds({
x: 110,
y: 110,
width: 440,
height: 440
});

expect(autoResizeSpy).to.be.calledWith([ hiddenContainedChild ], collapsedShape);
expect(autoResizeSpy).to.be.calledWith([ collapsedShape ], parentShape);
})
Expand All @@ -486,16 +534,20 @@ describe('features/auto-resize', function() {

collapsedShape = elementFactory.createShape({
id: 'collapsedShape',
x: 110, y: 110, width: 200, height: 200,
x: 110,
y: 110,
width: 200,
height: 200,
collapsed: true
});

canvas.addShape(collapsedShape, rootShape);

}));


it('should not resize on autoResize=false hint',
inject(function(eventBus, modeling, autoResize) {

// given
var autoResizeSpy = sinon.spy(autoResize, '_expand');

Expand All @@ -507,7 +559,13 @@ describe('features/auto-resize', function() {
modeling.toggleCollapse(collapsedShape);

// then
expect(collapsedShape).to.have.bounds({ x: 110, y: 110, width: 200, height: 200 });
expect(collapsedShape).to.have.bounds({
x: 110,
y: 110,
width: 200,
height: 200
});

expect(autoResizeSpy).to.not.be.called;
})
);
Expand Down

0 comments on commit 372e439

Please sign in to comment.