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,65 +680,83 @@ 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');
// when
createViewer(xml, function(err) {
// then it('should import default without bpmnDiagram specified', function(done) {
done(err);
// when
createViewer(multipleDiagramsXML, function(err) {
// then
done(err);
});
}); });
});
it('should import BPMN with multiple diagrams with diagram id specified', function(done) { it('should import bpmnDiagram specified by id', function(done) {
// given // when
var xml = require('../fixtures/bpmn/multiple-diagrams.bpmn'); createViewer(multipleDiagramsXML, 'Diagram_80fecfcd-0165-4c36-90b6-3ea384265fe7', function(err) {
// when // then
createViewer(xml, 'Diagram_80fecfcd-0165-4c36-90b6-3ea384265fe7', function(err) { done(err);
});
// then
done(err);
}); });
});
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');
// when // when
createViewer(xml, 'Diagram_IDontExist', function(err) { createViewer(xml, 'Diagram_IDontExist', function(err) {
// 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() {
// given it('should open default', function(done) {
var viewer = new Viewer({ container: container });
var xml = require('../fixtures/bpmn/multiple-diagrams.bpmn'); // given
var viewer = new Viewer({ container: container });
// when // when
viewer.importXML(xml); viewer.importXML(multipleDiagramsXML);
// then
viewer.on('import.done', function(event) {
done();
});
});
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();
});
});
// 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);