From 22686f7614cf2698fc7f8d5d9c7d8637405275ef Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Fri, 8 Jan 2016 14:41:58 +0100 Subject: [PATCH] fix(Viewer): allow canvas configuration Closes #444 --- lib/Viewer.js | 2 +- test/spec/ModelerSpec.js | 31 ++++++++++++++ test/spec/ViewerSpec.js | 90 ++++++++++++++++++++++++++-------------- 3 files changed, 92 insertions(+), 31 deletions(-) diff --git a/lib/Viewer.js b/lib/Viewer.js index 436fef36..22caac4c 100644 --- a/lib/Viewer.js +++ b/lib/Viewer.js @@ -285,7 +285,7 @@ Viewer.prototype._createDiagram = function(options) { options = omit(options, 'additionalModules'); options = assign(options, { - canvas: { container: this.container }, + canvas: assign({}, options.canvas, { container: this.container }), modules: modules }); diff --git a/test/spec/ModelerSpec.js b/test/spec/ModelerSpec.js index 27586d62..e12890d7 100644 --- a/test/spec/ModelerSpec.js +++ b/test/spec/ModelerSpec.js @@ -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) { var xml = 'invalid stuff'; diff --git a/test/spec/ViewerSpec.js b/test/spec/ViewerSpec.js index 4944c6f0..d1db2d34 100644 --- a/test/spec/ViewerSpec.js +++ b/test/spec/ViewerSpec.js @@ -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() { 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() { it('should remove traces in document tree', function() {