diff --git a/lib/Viewer.js b/lib/Viewer.js index d8e5fc88..8cb894b9 100644 --- a/lib/Viewer.js +++ b/lib/Viewer.js @@ -12,7 +12,7 @@ function getSvgContents(diagram) { var outerNode = diagram.get('canvas').getContainer(); var svg = outerNode.innerHTML; - return svg.replace(/^]*>|<\/svg>$/g, '') + return svg.replace(/.*]*>|<\/svg>.*$/g, '') .replace('Created with Snap', '') .replace(/YUP GREAT STUFF!' + }); + + // then + expect(overlays.get({ element: 'SubProcess_1' }).length).toBe(1); + + done(err); + }); + + }); + + }); + + it('should handle errors', function(done) { var xml = 'invalid stuff'; diff --git a/test/spec/ViewerSpec.js b/test/spec/ViewerSpec.js index 6181fc95..e74743aa 100644 --- a/test/spec/ViewerSpec.js +++ b/test/spec/ViewerSpec.js @@ -50,7 +50,7 @@ describe('viewer', function() { describe('import events', function() { - iit('should fire events', function(done) { + it('should fire events', function(done) { // given var viewer = new Viewer({ container: container }); @@ -87,6 +87,45 @@ describe('viewer', function() { }); + describe('overlay support', function() { + + it('should allow to add overlays', function(done) { + + var xml = fs.readFileSync('test/fixtures/bpmn/simple.bpmn', 'utf8'); + + createViewer(xml, function(err, viewer) { + + // when + var overlays = viewer.get('overlays'), + elementRegistry = viewer.get('elementRegistry'); + + // then + expect(overlays).toBeDefined(); + expect(elementRegistry).toBeDefined(); + + // given + var subProcessShape = elementRegistry.getById('SubProcess_1'); + + // when + overlays.add('SubProcess_1', { + position: { + bottom: 0, + right: 0 + }, + html: '
YUP GREAT STUFF!
' + }); + + // then + expect(overlays.get({ element: 'SubProcess_1' }).length).toBe(1); + + done(err); + }); + + }); + + }); + + describe('error handling', function() { it('should handle non-bpmn input', function(done) {