test(Viewer): group multiple diagram handling

This commit is contained in:
Nico Rehwaldt 2019-04-12 11:56:29 +02:00 committed by Nico Rehwaldt
parent daee95743d
commit a78f8037c7
1 changed files with 55 additions and 37 deletions

View File

@ -680,13 +680,15 @@ describe('Viewer', function() {
}); });
it('should import BPMN with multiple diagrams without diagram id specified', function(done) { describe('multiple BPMNDiagram elements', function() {
// given var multipleDiagramsXML = require('../fixtures/bpmn/multiple-diagrams.bpmn');
var xml = require('../fixtures/bpmn/multiple-diagrams.bpmn');
it('should import default without bpmnDiagram specified', function(done) {
// when // when
createViewer(xml, function(err) { createViewer(multipleDiagramsXML, function(err) {
// then // then
done(err); done(err);
@ -694,13 +696,10 @@ describe('Viewer', function() {
}); });
it('should import BPMN with multiple diagrams with diagram id specified', function(done) { it('should import bpmnDiagram specified by id', function(done) {
// given
var xml = require('../fixtures/bpmn/multiple-diagrams.bpmn');
// when // when
createViewer(xml, 'Diagram_80fecfcd-0165-4c36-90b6-3ea384265fe7', function(err) { createViewer(multipleDiagramsXML, 'Diagram_80fecfcd-0165-4c36-90b6-3ea384265fe7', function(err) {
// then // then
done(err); done(err);
@ -708,7 +707,7 @@ describe('Viewer', function() {
}); });
it('should complete with error if diagram of provided ID does not exist', function(done) { it('should handle diagram not found', function(done) {
// given // given
var xml = require('../fixtures/bpmn/multiple-diagrams.bpmn'); var xml = require('../fixtures/bpmn/multiple-diagrams.bpmn');
@ -718,22 +717,22 @@ describe('Viewer', function() {
// then // then
expect(err).to.exist; expect(err).to.exist;
expect(err.message).to.eql('no diagram to display'); expect(err.message).to.eql('BPMNDiagram <Diagram_IDontExist> not found');
done(); done();
}); });
}); });
it('should import BPMN with multiple diagrams when only xml is provided', function(done) { describe('without callback', function() {
it('should open default', function(done) {
// given // given
var viewer = new Viewer({ container: container }); var viewer = new Viewer({ container: container });
var xml = require('../fixtures/bpmn/multiple-diagrams.bpmn');
// when // when
viewer.importXML(xml); viewer.importXML(multipleDiagramsXML);
// then // then
viewer.on('import.done', function(event) { viewer.on('import.done', function(event) {
@ -741,6 +740,25 @@ describe('Viewer', function() {
}); });
}); });
it('should open specified BPMNDiagram', function(done) {
// given
var viewer = new Viewer({ container: container });
// when
viewer.importXML(multipleDiagramsXML, 'Diagram_80fecfcd-0165-4c36-90b6-3ea384265fe7');
// then
viewer.on('import.done', function(event) {
done();
});
});
});
});
}); });
@ -818,7 +836,7 @@ describe('Viewer', function() {
// then // then
expect(err).to.exist; expect(err).to.exist;
expect(err.message).to.eql('no diagram to display'); expect(err.message).to.eql('BPMNDiagram <Diagram_IDontExist> not found');
// definitions stay the same // definitions stay the same
expect(viewer.getDefinitions()).to.eql(definitions); expect(viewer.getDefinitions()).to.eql(definitions);