diff --git a/lib/import/Importer.js b/lib/import/Importer.js index 19915ace..f946d09e 100644 --- a/lib/import/Importer.js +++ b/lib/import/Importer.js @@ -43,7 +43,7 @@ function importBpmnDiagram(diagram, definitions, done) { walker.handleDefinitions(definitions); } - eventBus.fire('import.start'); + eventBus.fire('import.start', { definitions: definitions }); try { parse(definitions); diff --git a/test/spec/import/ImporterSpec.js b/test/spec/import/ImporterSpec.js index e2dcad7f..dda177b5 100644 --- a/test/spec/import/ImporterSpec.js +++ b/test/spec/import/ImporterSpec.js @@ -43,7 +43,41 @@ describe('import - Importer', function() { } - describe('event emitter', function() { + describe('events', function() { + + it('should fire and ', function(done) { + + // given + var xml = require('../../fixtures/bpmn/import/process.bpmn'); + + var eventCount = 0; + + var eventBus = diagram.get('eventBus'); + + // log events + eventBus.on('import.start', function(event) { + expect(event.definitions).to.exist; + + eventCount++; + }); + + eventBus.on('import.success', function(event) { + expect(event).to.have.property('error'); + expect(event).to.have.property('warnings'); + + eventCount++; + }); + + // when + runImport(diagram, xml, function(err, warnings) { + + // then + expect(eventCount).to.equal(2); + + done(err); + }); + }); + it('should fire during import', function(done) {