bpmn-js/test/spec/draw/TextRendererSpec.js
Philipp Fromme 891cf4ac0c feat(draw+modeling): support lineHeight
* take numeric line height into account when
  rendering text labels
* take line height into account when directly
  editing labels
* use default line height of 1.2 for text rendering

Closes #803
2018-05-29 11:58:15 +02:00

88 lines
1.8 KiB
JavaScript

import {
bootstrapViewer,
inject
} from 'test/TestHelper';
describe('draw - TextRenderer', function() {
var diagramXML = require('./TextRenderer.bpmn');
describe('API', function() {
beforeEach(bootstrapViewer(diagramXML));
it('should expose #createText', inject(function(textRenderer) {
// when
var text = textRenderer.createText('FOO');
// then
expect(text).to.exist;
}));
it('should expose #getLayoutedBounds', inject(function(textRenderer) {
// given
var bounds = {
x: 0,
y: 0,
width: 100,
height: 100
};
// when
var layoutedBounds = textRenderer.getLayoutedBounds(
bounds,
'FOO\nBar\nFOOBAR'
);
// then
expect(layoutedBounds).to.exist;
expect(layoutedBounds.x).to.exist;
expect(layoutedBounds.y).to.exist;
expect(layoutedBounds.width).to.exist;
expect(layoutedBounds.height).to.exist;
}));
});
describe('style override', function() {
beforeEach(bootstrapViewer(diagramXML, {
textRenderer: {
defaultStyle: {
fontFamily: 'monospace',
fontSize: '15px',
lineHeight: '24px'
},
externalStyle: {
fontWeight: 'bold'
}
}
}));
it('should render', inject(function(textRenderer) {
// when
var defaultStyle = textRenderer.getDefaultStyle();
var externalStyle = textRenderer.getExternalStyle();
// then
expect(defaultStyle.fontFamily).to.eql('monospace');
expect(defaultStyle.fontSize).to.eql('15px');
expect(defaultStyle.lineHeight).to.eql('24px');
expect(externalStyle.fontFamily).to.eql('monospace');
expect(externalStyle.fontSize).to.eql(14);
expect(externalStyle.fontWeight).to.eql('bold');
}));
});
});