Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

diagram-js

Package Overview
Dependencies
Maintainers
4
Versions
288
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

diagram-js - npm Package Compare versions

Comparing version 0.19.6 to 0.20.0

test/spec/features/modeling/CreateConnectionSpec.js

7

lib/core/Canvas.js

@@ -957,10 +957,3 @@ 'use strict';

var transformBBox = gfx.getBBox(true);
bbox = gfx.getBBox();
bbox.x -= transformBBox.x;
bbox.y -= transformBBox.y;
bbox.width += 2 * transformBBox.x;
bbox.height += 2 * transformBBox.y;
}

@@ -967,0 +960,0 @@ // shapes

4

lib/features/attach-support/AttachSupport.js

@@ -56,2 +56,6 @@ 'use strict';

modeling.moveShape(attacher, delta, newParent);
if (attacher.label) {
modeling.moveShape(attacher.label, delta, newParent);
}
}

@@ -58,0 +62,0 @@ });

@@ -68,6 +68,5 @@ 'use strict';

// if they have not been moved already
forEach(enclosedElements, function(e) {
if (e.label && !enclosedElements[e.label.id]) {
modeling.moveShape(e.label, context.delta, e.parent);
forEach(enclosedElements, function(element) {
if (element.label && !enclosedElements[element.label.id]) {
modeling.moveShape(element.label, context.delta, element.parent);
}

@@ -74,0 +73,0 @@ });

@@ -31,2 +31,3 @@ 'use strict';

parent = context.parent,
parentIndex = context.parentIndex,
hints = context.hints;

@@ -50,3 +51,3 @@

// add connection
this._canvas.addConnection(connection, parent);
this._canvas.addConnection(connection, parent, parentIndex);

@@ -53,0 +54,0 @@ return connection;

@@ -20,17 +20,10 @@ 'use strict';

var connection = context.connection,
parent = connection.parent,
connectionSiblings = parent.children;
var connection = context.connection;
var oldIndex = connectionSiblings.indexOf(connection);
var oldWaypoints = connection.waypoints;
assign(context, {
oldWaypoints: oldWaypoints,
oldIndex: oldIndex
oldWaypoints: oldWaypoints
});
sendToFront(connection);
connection.waypoints = this._layouter.layoutConnection(connection, context.hints);

@@ -43,53 +36,7 @@

var connection = context.connection,
parent = connection.parent,
connectionSiblings = parent.children,
currentIndex = connectionSiblings.indexOf(connection),
oldIndex = context.oldIndex;
var connection = context.connection;
connection.waypoints = context.oldWaypoints;
if (oldIndex !== currentIndex) {
// change position of connection in shape
connectionSiblings.splice(currentIndex, 1);
connectionSiblings.splice(oldIndex, 0, connection);
}
return connection;
};
////////////// helpers /////////////////////////////////////
// connections should have a higher z-order as there source and targets
function sendToFront(connection) {
var connectionSiblings = connection.parent.children;
var connectionIdx = connectionSiblings.indexOf(connection),
sourceIdx = findIndex(connectionSiblings, connection.source),
targetIdx = findIndex(connectionSiblings, connection.target),
// ensure we do not send the connection back
// if it is already in front
insertIndex = Math.max(sourceIdx + 1, targetIdx + 1, connectionIdx);
if (connectionIdx < insertIndex) {
connectionSiblings.splice(insertIndex, 0, connection); // add to new position
connectionSiblings.splice(connectionIdx, 1); // remove from old position
}
function findIndex(array, obj) {
var index = array.indexOf(obj);
if (index < 0 && obj) {
var parent = obj.parent;
index = findIndex(array, parent);
}
return index;
}
return insertIndex;
}

@@ -196,9 +196,9 @@ 'use strict';

*/
Modeling.prototype.createConnection = function(source, target, targetIndex, connection, parent, hints) {
Modeling.prototype.createConnection = function(source, target, parentIndex, connection, parent, hints) {
if (typeof targetIndex === 'object') {
if (typeof parentIndex === 'object') {
hints = parent;
parent = connection;
connection = targetIndex;
targetIndex = undefined;
connection = parentIndex;
parentIndex = undefined;
}

@@ -212,3 +212,3 @@

parent: parent,
parentIndex: targetIndex,
parentIndex: parentIndex,
connection: connection,

@@ -223,7 +223,7 @@ hints: hints

Modeling.prototype.createShape = function(shape, position, target, targetIndex, isAttach, hints) {
Modeling.prototype.createShape = function(shape, position, parent, parentIndex, isAttach, hints) {
if (typeof targetIndex !== 'number') {
if (typeof parentIndex !== 'number') {
hints = isAttach;
isAttach = targetIndex;
isAttach = parentIndex;
}

@@ -241,4 +241,4 @@

shape: shape,
parent: target,
parentIndex: targetIndex,
parent: parent,
parentIndex: parentIndex,
host: shape.host,

@@ -249,4 +249,4 @@ hints: hints || {}

if (isAttach) {
context.parent = target.parent;
context.host = target;
context.parent = parent.parent;
context.host = parent;
}

@@ -253,0 +253,0 @@

@@ -245,6 +245,6 @@ 'use strict';

// snap to all non connection siblings
// snap to all siblings that are not hidden, labels, attached to element or element itself
return target && filter(target.children, function(e) {
return !e.hidden && !e.labelTarget && !e.waypoints && e.host !== element && e !== element;
return !e.hidden && !e.labelTarget && e.host !== element && e !== element;
});
};

@@ -93,3 +93,3 @@ 'use strict';

// try to fit
if (fitLine === ' ' || fitLine === '' || textBBox.width < Math.round(maxWidth) || fitLine.length < 4) {
if (fitLine === ' ' || fitLine === '' || textBBox.width < Math.round(maxWidth) || fitLine.length < 2) {
return fit(lines, fitLine, originalLine, textBBox);

@@ -104,12 +104,5 @@ }

if (fitLine.length < originalLine.length) {
var nextLine = lines[0] || '',
remainder = originalLine.slice(fitLine.length).trim();
var remainder = originalLine.slice(fitLine.length).trim();
if (/-\s*$/.test(remainder)) {
nextLine = remainder + nextLine.replace(/^\s+/, '');
} else {
nextLine = remainder + ' ' + nextLine;
}
lines[0] = nextLine;
lines.unshift(remainder);
}

@@ -116,0 +109,0 @@ return { width: textBBox.width, height: textBBox.height, text: fitLine };

{
"name": "diagram-js",
"version": "0.19.6",
"version": "0.20.0",
"description": "A modeling framework for the web",

@@ -5,0 +5,0 @@ "scripts": {

@@ -1877,102 +1877,230 @@ 'use strict';

it('should move attacher label to the right', inject(function(spaceTool, dragging, elementFactory, modeling) {
describe('resize host', function() {
// given
var attacher = createAttacher({ x: 400, y: 200 }),
label = elementFactory.createLabel({ width: 80, height: 40 });
it('should move attacher label to the right', inject(function(spaceTool, dragging, elementFactory, modeling) {
modeling.createLabel(attacher, {
x: attacher.x,
y: attacher.y
}, label, parentShape);
// given
var attacher = createAttacher({ x: 400, y: 200 }),
label = elementFactory.createLabel({ width: 80, height: 40 });
var labelPosition = {
x: attacher.label.x,
y: attacher.label.y
};
modeling.createLabel(attacher, {
x: attacher.x,
y: attacher.y
}, label, parentShape);
// when
spaceTool.activateMakeSpace(canvasEvent({ x: 340, y: 100 }));
var labelPosition = {
x: attacher.label.x,
y: attacher.label.y
};
dragging.move(canvasEvent({ x: 440, y: 100 }));
dragging.end();
// when
spaceTool.activateMakeSpace(canvasEvent({ x: 340, y: 100 }));
// then
expect({
x: attacher.label.x,
y: attacher.label.y
}).to.eql({
x: labelPosition.x + 100,
y: labelPosition.y
});
}));
dragging.move(canvasEvent({ x: 440, y: 100 }));
dragging.end();
// then
expect({
x: attacher.label.x,
y: attacher.label.y
}).to.eql({
x: labelPosition.x + 100,
y: labelPosition.y
});
}));
it('should move attacher label down', inject(function(spaceTool, dragging, elementFactory, modeling) {
// given
var attacher = createAttacher({ x: 250, y: 400 }),
label = elementFactory.createLabel({ width: 80, height: 40 });
it('should move attacher label down', inject(function(spaceTool, dragging, elementFactory, modeling) {
modeling.createLabel(attacher, {
x: attacher.x,
y: attacher.y
}, label, parentShape);
// given
var attacher = createAttacher({ x: 250, y: 400 }),
label = elementFactory.createLabel({ width: 80, height: 40 });
var labelPosition = {
x: attacher.label.x,
y: attacher.label.y
};
modeling.createLabel(attacher, {
x: attacher.x,
y: attacher.y
}, label, parentShape);
// when
spaceTool.activateMakeSpace(canvasEvent({ x: 250, y: 200 }));
var labelPosition = {
x: attacher.label.x,
y: attacher.label.y
};
dragging.move(canvasEvent({ x: 250, y: 220 }));
dragging.end();
// when
spaceTool.activateMakeSpace(canvasEvent({ x: 250, y: 200 }));
// then
expect({
x: attacher.label.x,
y: attacher.label.y
}).to.eql({
x: labelPosition.x,
y: labelPosition.y + 20
});
}));
dragging.move(canvasEvent({ x: 250, y: 220 }));
dragging.end();
// then
expect({
x: attacher.label.x,
y: attacher.label.y
}).to.eql({
x: labelPosition.x,
y: labelPosition.y + 20
});
}));
it('should move attacher label to the left', inject(function(spaceTool, dragging, elementFactory, modeling) {
// given
var attacher = createAttacher({ x: 100, y: 200 }),
label = elementFactory.createLabel({ width: 80, height: 40 });
it('should move attacher label to the left', inject(function(spaceTool, dragging, elementFactory, modeling) {
modeling.createLabel(attacher, {
x: attacher.x,
y: attacher.y
}, label, parentShape);
// given
var attacher = createAttacher({ x: 100, y: 200 }),
label = elementFactory.createLabel({ width: 80, height: 40 });
var labelPosition = {
x: attacher.label.x,
y: attacher.label.y
};
modeling.createLabel(attacher, {
x: attacher.x,
y: attacher.y
}, label, parentShape);
// when
spaceTool.activateMakeSpace(canvasEvent({ x: 300, y: 100 }));
var labelPosition = {
x: attacher.label.x,
y: attacher.label.y
};
dragging.move(canvasEvent({ x: 260, y: 100 }, keyModifier));
dragging.end();
// when
spaceTool.activateMakeSpace(canvasEvent({ x: 300, y: 100 }));
// then
expect({
x: attacher.label.x,
y: attacher.label.y
}).to.eql({
x: labelPosition.x - 40,
y: labelPosition.y
});
}));
dragging.move(canvasEvent({ x: 260, y: 100 }, keyModifier));
dragging.end();
// then
expect({
x: attacher.label.x,
y: attacher.label.y
}).to.eql({
x: labelPosition.x - 40,
y: labelPosition.y
});
}));
it('should not move attacher when host has not been resized',
inject(function(spaceTool, dragging, elementFactory, modeling, canvas) {
// given
parentShape.resizable = false;
var attacher = createAttacher({ x: 300, y: 400 }),
attacherPosition = { x: attacher.x, y: attacher.y };
// when
spaceTool.activateMakeSpace(canvasEvent({ x: 300, y: 150 }));
dragging.move(canvasEvent({ x: 300, y: 250 }));
dragging.end();
// then
expect(attacher.x).to.eql(attacherPosition.x);
expect(attacher.y).to.eql(attacherPosition.y);
})
);
});
describe('move host', function() {
it('should move attacher label to the right', inject(function(spaceTool, dragging, elementFactory, modeling) {
// given
var attacher = createAttacher({ x: 400, y: 200 }),
label = elementFactory.createLabel({ width: 80, height: 40 });
modeling.createLabel(attacher, {
x: attacher.x,
y: attacher.y
}, label, rootShape);
var labelPosition = {
x: attacher.label.x,
y: attacher.label.y
};
// when
spaceTool.activateMakeSpace(canvasEvent({ x: 50, y: 100 }));
dragging.move(canvasEvent({ x: 150, y: 100 }));
dragging.end();
// then
expect({
x: attacher.label.x,
y: attacher.label.y
}).to.eql({
x: labelPosition.x + 100,
y: labelPosition.y
});
}));
it('should move attacher label down', inject(function(spaceTool, dragging, elementFactory, modeling) {
// given
var attacher = createAttacher({ x: 250, y: 425 }),
label = elementFactory.createLabel({ width: 80, height: 40 });
modeling.createLabel(attacher, {
x: attacher.x,
y: attacher.y
}, label, rootShape);
var labelPosition = {
x: attacher.label.x,
y: attacher.label.y
};
// when
spaceTool.activateMakeSpace(canvasEvent({ x: 50, y: 50 }));
dragging.move(canvasEvent({ x: 50, y: 100 }));
dragging.end();
// then
expect({
x: attacher.label.x,
y: attacher.label.y
}).to.eql({
x: labelPosition.x,
y: labelPosition.y + 50
});
}));
it('should move attacher label to the left', inject(function(spaceTool, dragging, elementFactory, modeling) {
// given
var attacher = createAttacher({ x: 100, y: 200 }),
label = elementFactory.createLabel({ width: 80, height: 40 });
modeling.createLabel(attacher, {
x: attacher.x,
y: attacher.y
}, label, rootShape);
var labelPosition = {
x: attacher.label.x,
y: attacher.label.y
};
// when
spaceTool.activateMakeSpace(canvasEvent({ x: 500, y: 100 }));
dragging.move(canvasEvent({ x: 480, y: 100 }, keyModifier));
dragging.end();
// then
expect({
x: attacher.label.x,
y: attacher.label.y
}).to.eql({
x: labelPosition.x - 20,
y: labelPosition.y
});
}));
});
});
});

@@ -69,3 +69,3 @@ 'use strict';

return shape.attachers.length > 0;
return shape.attachers.length > 0 && shape.resizable !== false;
});

@@ -72,0 +72,0 @@ };

@@ -10,3 +10,4 @@ 'use strict';

modelingModule = require('../../../../lib/features/modeling'),
rulesModule = require('./rules');
rulesModule = require('./rules'),
spaceToolModule = require('../../../../lib/features/space-tool');

@@ -17,3 +18,3 @@ var svgClasses = require('tiny-svg/lib/classes');

beforeEach(bootstrapDiagram({ modules: [ labelSupportModule, modelingModule, rulesModule ] }));
beforeEach(bootstrapDiagram({ modules: [ labelSupportModule, modelingModule, rulesModule, spaceToolModule ] }));

@@ -25,3 +26,3 @@ beforeEach(inject(function(canvas, dragging) {

var rootShape, parentShape, childShape, label;
var rootShape, parentShape, childShape, label, hostShape, attacherShape, attacherLabel;

@@ -58,2 +59,28 @@ beforeEach(inject(function(elementFactory, canvas, modeling) {

modeling.createLabel(childShape, { x: 200, y: 250 }, label, parentShape);
hostShape = elementFactory.createShape({
id: 'host',
x: 500, y: 100,
width: 100, height: 100
});
canvas.addShape(hostShape, rootShape);
attacherShape = elementFactory.createShape({
id: 'attacher',
x: 525, y: 175,
width: 50, height: 50,
parent: rootShape,
host: hostShape
});
canvas.addShape(attacherShape, hostShape);
attacherLabel = elementFactory.createLabel({
id: 'attacherLabel',
width: 80, height: 40,
type: 'label'
});
modeling.createLabel(attacherShape, { x: 550, y: 250 }, attacherLabel, rootShape);
}));

@@ -136,2 +163,52 @@

describe('space tool', function() {
var attacherLabelPos;
beforeEach(function() {
attacherLabelPos = { x: attacherLabel.x, y: attacherLabel.y };
});
describe('should move label along with its target', function() {
beforeEach(inject(function(spaceTool, dragging) {
// when
spaceTool.activateMakeSpace(canvasEvent({ x: 250, y: 100 }));
dragging.move(canvasEvent({ x: 250, y: 200 }));
dragging.end();
}));
it('execute', inject(function(spaceTool, dragging) {
// then
expect(attacherLabel.x).to.eql(attacherLabelPos.x);
expect(attacherLabel.y).to.eql(attacherLabelPos.y + 100);
}));
it('undo', inject(function(commandStack) {
// when
commandStack.undo();
// then
expect(attacherLabel.x).to.eql(attacherLabelPos.x);
expect(attacherLabel.y).to.eql(attacherLabelPos.y);
}));
it('redo', inject(function(commandStack) {
// when
commandStack.undo();
commandStack.redo();
// then
expect(attacherLabel.x).to.eql(attacherLabelPos.x);
expect(attacherLabel.y).to.eql(attacherLabelPos.y + 100);
}));
});
});
it('should keep on top of labelTarget', inject(function(move, dragging) {

@@ -138,0 +215,0 @@

@@ -17,3 +17,3 @@ 'use strict';

var rootShape, parentShape, childShape;
var rootShape, parentShape, newShape;

@@ -35,4 +35,4 @@ beforeEach(inject(function(elementFactory, canvas) {

childShape = elementFactory.createShape({
id: 'childShape',
newShape = elementFactory.createShape({
id: 'newShape',
x: 0, y: 0, width: 100, height: 100

@@ -51,26 +51,48 @@ });

it('should create a shape', inject(function(modeling, elementRegistry) {
describe('should create', function() {
// when
modeling.createShape(childShape, position, parentShape);
it('execute', inject(function(modeling, elementRegistry) {
var shape = elementRegistry.get('childShape');
// when
modeling.createShape(newShape, position, parentShape);
// then
expect(shape).to.include({
id: 'childShape',
x: 125, y: 125,
width: 100, height: 100
});
var shape = elementRegistry.get('newShape');
}));
// then
expect(shape).to.include({
id: 'newShape',
x: 125, y: 125,
width: 100, height: 100
});
}));
it('undo', inject(function(modeling, commandStack, elementRegistry) {
// given
modeling.createShape(newShape, position, parentShape);
// when
commandStack.undo();
var shape = elementRegistry.get('newShape');
// then
expect(shape).to.not.exist;
expect(newShape.parent).not.to.exist;
expect(parentShape.children).not.to.contain(newShape);
}));
});
it('should have a parent', inject(function(modeling) {
// given
modeling.createShape(childShape, position, parentShape);
modeling.createShape(newShape, position, parentShape);
// when
var parent = childShape.parent;
var parent = newShape.parent;

@@ -82,27 +104,28 @@ // then

it('should return a graphics element', inject(function(modeling, elementRegistry) {
it('should have parentIndex', inject(function(modeling) {
// given
modeling.createShape(childShape, position, parentShape);
modeling.createShape(newShape, position, rootShape, 0);
// when
var shape = elementRegistry.getGraphics(childShape);
var children = rootShape.children;
// then
expect(shape).to.exist;
expect(children).to.eql([
newShape,
parentShape
]);
}));
it('should undo', inject(function(modeling, commandStack, elementRegistry) {
it('should return a graphics element', inject(function(modeling, elementRegistry) {
// given
modeling.createShape(childShape, position, parentShape);
modeling.createShape(newShape, position, parentShape);
// when
commandStack.undo();
var shape = elementRegistry.getGraphics(newShape);
var shape = elementRegistry.get('childShape');
// then
expect(shape).to.not.exist;
expect(shape).to.exist;
}));

@@ -109,0 +132,0 @@

@@ -123,5 +123,9 @@ 'use strict';

describe('correct z-order', function() {
describe('z-order handling', function() {
var container1, container2, sourceShape, targetShape, connection;
var container1,
container2,
sourceShape,
targetShape,
connection;

@@ -170,3 +174,3 @@ beforeEach(inject(function(elementFactory, canvas) {

describe('send to front after moving target to nested child', function() {
describe('keep z-index after moving target to nested child', function() {

@@ -179,7 +183,9 @@ it('should execute', inject(function(modeling) {

// then
var childArr = connection.parent.children;
var connectionSiblings = connection.parent.children;
expect(childArr[0]).to.equal(sourceShape);
expect(childArr[1]).to.equal(container1);
expect(childArr[2]).to.equal(connection);
expect(connectionSiblings).to.eql([
sourceShape,
connection,
container1
]);
}));

@@ -197,8 +203,10 @@

// then
var childArr = connection.parent.children;
var connectionSiblings = connection.parent.children;
expect(childArr[0]).to.equal(sourceShape);
expect(childArr[1]).to.equal(targetShape);
expect(childArr[2]).to.equal(connection);
expect(childArr[3]).to.equal(container1);
expect(connectionSiblings).to.eql([
sourceShape,
targetShape,
connection,
container1
]);
}));

@@ -208,28 +216,4 @@

it('should leave unchanged if already in front', inject(function(canvas, modeling) {
// given
var connection2 = canvas.addConnection({
id: 'connection2',
waypoints: [ { x: 60, y: 60 }, { x: 150, y: 150 }, { x: 200, y: 60 } ],
source: sourceShape,
target: targetShape
});
// when
modeling.moveShape(targetShape, { x: 0, y: 200 }, container2);
// then
var childArr = connection2.parent.children;
expect(childArr[0]).to.equal(sourceShape);
expect(childArr[1]).to.equal(container1);
expect(childArr[2]).to.equal(connection);
expect(childArr[3]).to.equal(connection2);
}));
});
});

@@ -13,3 +13,9 @@ 'use strict';

beforeEach(bootstrapDiagram({ modules: [ moveModule, modelingModule, orderingProviderModule ] }));
beforeEach(bootstrapDiagram({
modules: [
moveModule,
modelingModule,
orderingProviderModule
]
}));

@@ -147,2 +153,27 @@

describe('should handle connection order', function() {
it('should create connection behind shapes', inject(function(modeling, elementFactory) {
// given
var newConnection = elementFactory.createConnection({
id: 'newConnection',
level: 0
});
// when
modeling.connect(nestedLevel1Shape, nestedLevel2Shape, newConnection);
// then
expect(level3Shape_Parent.children).to.eql([
newConnection,
nestedLevel1Shape,
nestedLevel2Shape
]);
}));
});
});

@@ -10,3 +10,4 @@ 'use strict';

moveModule = require('../../../lib/features/move'),
createModule = require('../../../lib/features/create');
createModule = require('../../../lib/features/create'),
attachSupportModule = require('../../../lib/features/attach-support');

@@ -24,3 +25,3 @@ var canvasEvent = require('../../util/MockEvents').createCanvasEvent;

beforeEach(bootstrapDiagram({ modules: [ snappingModule ] }));
beforeEach(bootstrapDiagram({ modules: [ modelingModule, snappingModule ] }));

@@ -196,2 +197,59 @@

describe('util', function() {
beforeEach(bootstrapDiagram({ modules: [ modelingModule, snappingModule, attachSupportModule ] }));
var rootElement, shape, sibling;
beforeEach(inject(function(canvas, elementFactory) {
rootElement = elementFactory.createRoot({
id: 'root'
});
canvas.setRootElement(rootElement);
shape = canvas.addShape(elementFactory.createShape({
id: 'shape1',
x: 100, y: 100, width: 100, height: 100
}));
sibling = canvas.addShape(elementFactory.createShape({
id: 'shape2',
x: 400, y: 150, width: 50, height: 50
}));
}));
it('getSiblings', inject(function(canvas, elementFactory, modeling, snapping) {
// given
var attacher = elementFactory.createShape({
id: 'attacher',
width: 50, height: 50
});
modeling.createShape(attacher, { x: 100, y: 100 }, shape, true);
var label = elementFactory.createLabel({
id: 'label',
width: 80, height: 40
});
modeling.createLabel(shape, { x: 150, y: 250 }, label, rootElement);
var connection = modeling.connect(shape, sibling);
// when
var siblings = snapping.getSiblings(shape, rootElement);
// then
expect(siblings).to.have.length(2);
expect(siblings).to.contain(sibling);
expect(siblings).to.contain(connection);
}));
});
describe('integration', function() {

@@ -198,0 +256,0 @@

@@ -64,3 +64,3 @@ 'use strict';

parent.style.width = '200px';
parent.style.height = '200px';
parent.style.height = '400px';
parent.style.display = 'inline-block';

@@ -148,3 +148,3 @@

expect(text).to.exist;
expect(toFitBBox(text, { x: -1, y: 3, width: 32, height: 320 })).to.be.true;
expect(toFitBBox(text, { x: -1, y: 3, width: 40, height: 320 })).to.be.true;
});

@@ -162,3 +162,3 @@

expect(text).to.exist;
expect(toFitBBox(text, { x: -1, y: 3, width: 32, height: 195 })).to.be.true;
expect(toFitBBox(text, { x: -1, y: 3, width: 40, height: 230 })).to.be.true;
});

@@ -261,3 +261,3 @@

// given
var label = 'Some superdooooper-\nlong-\nword in the middle';
var label = 'Some superdooooper-long-word in the middle';

@@ -285,3 +285,3 @@ // when

expect(text).to.exist;
expect(toFitBBox(text, { x: 2, y: 0, width: 150, height: 100 })).to.be.true;
expect(toFitBBox(text, { x: 2, y: 0, width: 150, height: 105 })).to.be.true;
});

@@ -293,3 +293,3 @@

// given
var label = 'Line\n\n\nBreaks';
var label = 'Line breaks line breaks line\n\n\nBreaks';

@@ -392,20 +392,2 @@ // when

it('center-middle / preformated using line breaks (fixed box)', function() {
// given
var label = 'I am\na long label that\r\nshould break on line breaks';
// when
var text = createText(container, label, {
box: { width: 100, height: 100 },
fitBox: true,
align: 'center-middle',
padding: 5
});
expect(text).to.exist;
expect(toFitBBox(text, { x: 0, y: 0, width: 150, height: 100 })).to.be.true;
});
it('center-middle / vertical float out (fit box)', function() {

@@ -412,0 +394,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc