fix(Viewer): allow canvas configuration

Closes #444
This commit is contained in:
Nico Rehwaldt 2016-01-08 14:41:58 +01:00
parent ac910a9082
commit 22686f7614
3 changed files with 92 additions and 31 deletions

View File

@ -285,7 +285,7 @@ Viewer.prototype._createDiagram = function(options) {
options = omit(options, 'additionalModules'); options = omit(options, 'additionalModules');
options = assign(options, { options = assign(options, {
canvas: { container: this.container }, canvas: assign({}, options.canvas, { container: this.container }),
modules: modules modules: modules
}); });

View File

@ -185,6 +185,37 @@ describe('Modeler', function() {
}); });
describe('configuration', function() {
// given
var xml = require('../fixtures/bpmn/simple.bpmn');
it('should configure Canvas', function(done) {
// given
var modeler = new Modeler({
container: container,
canvas: {
deferUpdate: true
}
});
// when
modeler.importXML(xml, function(err) {
var canvasConfig = modeler.get('config.canvas');
// then
expect(canvasConfig.deferUpdate).to.be.true;
done();
});
});
});
it('should handle errors', function(done) { it('should handle errors', function(done) {
var xml = 'invalid stuff'; var xml = 'invalid stuff';

View File

@ -113,36 +113,6 @@ describe('Viewer', function() {
}); });
describe('#on', function() {
it('should fire with given three', function(done) {
// given
var viewer = new Viewer({ container: container });
var xml = require('../fixtures/bpmn/simple.bpmn');
// when
viewer.on('foo', 1000, function() {
return 'bar';
}, viewer);
// then
viewer.importXML(xml, function(err) {
var eventBus = viewer.get('eventBus');
var result = eventBus.fire('foo');
expect(result).to.equal('bar');
done();
});
});
});
describe('overlay support', function() { describe('overlay support', function() {
it('should allow to add overlays', function(done) { it('should allow to add overlays', function(done) {
@ -566,6 +536,66 @@ describe('Viewer', function() {
}); });
describe('configuration', function() {
var xml = require('../fixtures/bpmn/simple.bpmn');
it('should configure Canvas', function(done) {
// given
var viewer = new Viewer({
container: container,
canvas: {
deferUpdate: true
}
});
// when
viewer.importXML(xml, function(err) {
var canvasConfig = viewer.get('config.canvas');
// then
expect(canvasConfig.deferUpdate).to.be.true;
done();
});
});
});
describe('#on', function() {
it('should fire with given three', function(done) {
// given
var viewer = new Viewer({ container: container });
var xml = require('../fixtures/bpmn/simple.bpmn');
// when
viewer.on('foo', 1000, function() {
return 'bar';
}, viewer);
// then
viewer.importXML(xml, function(err) {
var eventBus = viewer.get('eventBus');
var result = eventBus.fire('foo');
expect(result).to.equal('bar');
done();
});
});
});
describe('#destroy', function() { describe('#destroy', function() {
it('should remove traces in document tree', function() { it('should remove traces in document tree', function() {