Fixing failing tests

This commit is contained in:
Jeff Avallone 2017-07-29 21:10:48 -04:00
parent bf97c596c9
commit 9d69be4c61
2 changed files with 7 additions and 5 deletions

View File

@ -99,7 +99,7 @@ describe('parser/javascript/charset.js', function() {
this.node.elements[1].render.and.returnValue(this.elementDeferred[1].promise); this.node.elements[1].render.and.returnValue(this.elementDeferred[1].promise);
this.node.elements[2].render.and.returnValue(this.elementDeferred[2].promise); this.node.elements[2].render.and.returnValue(this.elementDeferred[2].promise);
this.node.container = Snap(document.createElement('svg')); this.node.container = Snap(document.createElement('svg')).group();
this.partContainer = this.node.container.group(); this.partContainer = this.node.container.group();
spyOn(this.node.container, 'group').and.returnValue(this.partContainer); spyOn(this.node.container, 'group').and.returnValue(this.partContainer);
spyOn(this.partContainer, 'group').and.callFake(function() { spyOn(this.partContainer, 'group').and.callFake(function() {

View File

@ -164,7 +164,9 @@ export default class Node {
return this.deferredStep() return this.deferredStep()
.then(() => { .then(() => {
let labelBox = label.getBBox(), let labelBox = label.getBBox(),
contentBox = content.getBBox(); contentBox = content.getBBox(),
boxWidth = Math.max(contentBox.width + options.padding * 2, labelBox.width),
boxHeight = contentBox.height + options.padding * 2;
label.transform(Snap.matrix() label.transform(Snap.matrix()
.translate(0, labelBox.height)); .translate(0, labelBox.height));
@ -173,12 +175,12 @@ export default class Node {
.transform(Snap.matrix() .transform(Snap.matrix()
.translate(0, labelBox.height)) .translate(0, labelBox.height))
.attr({ .attr({
width: Math.max(contentBox.width + options.padding * 2, labelBox.width), width: boxWidth,
height: contentBox.height + options.padding * 2 height: boxHeight
}); });
content.transform(Snap.matrix() content.transform(Snap.matrix()
.translate(box.getBBox().cx - contentBox.cx, labelBox.height + options.padding)); .translate(boxWidth / 2 - contentBox.cx, labelBox.height + options.padding));
}); });
} }
}; };