2018-04-02 19:01:53 +00:00
|
|
|
import BpmnModdle from 'bpmn-moddle';
|
2014-09-08 17:04:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
describe('bpmn-moddle', function() {
|
|
|
|
|
2020-04-16 05:49:59 +00:00
|
|
|
function parse(xml) {
|
2014-09-08 17:04:07 +00:00
|
|
|
var moddle = new BpmnModdle();
|
2020-04-16 05:49:59 +00:00
|
|
|
return moddle.fromXML(xml, 'bpmn:Definitions');
|
2014-09-08 17:04:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
describe('browser support', function() {
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should parse simple xml', function() {
|
2014-09-08 17:04:07 +00:00
|
|
|
|
|
|
|
var xml =
|
|
|
|
'<?xml version="1.0" encoding="UTF-8"?>' +
|
|
|
|
'<bpmn2:definitions xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
|
|
|
|
'id="simple" ' +
|
|
|
|
'targetNamespace="http://bpmn.io/schema/bpmn">' +
|
|
|
|
'<bpmn2:process id="Process_1"></bpmn2:process>' +
|
|
|
|
'</bpmn2:definitions>';
|
|
|
|
|
|
|
|
// when
|
2020-04-29 09:02:42 +00:00
|
|
|
return parse(xml).then(function(result) {
|
2014-09-08 17:04:07 +00:00
|
|
|
|
2020-04-16 05:49:59 +00:00
|
|
|
var definitions = result.rootElement;
|
2014-09-08 17:04:07 +00:00
|
|
|
|
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(definitions.id).to.equal('simple');
|
|
|
|
expect(definitions.targetNamespace).to.equal('http://bpmn.io/schema/bpmn');
|
2014-09-08 17:04:07 +00:00
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(definitions.rootElements.length).to.equal(1);
|
|
|
|
expect(definitions.rootElements[0].id).to.equal('Process_1');
|
2014-09-08 17:04:07 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2020-04-29 09:02:42 +00:00
|
|
|
it('should parse complex xml', function() {
|
2014-09-08 17:04:07 +00:00
|
|
|
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/complex.bpmn');
|
2014-09-08 17:04:07 +00:00
|
|
|
|
|
|
|
var start = new Date().getTime();
|
|
|
|
|
|
|
|
// when
|
2020-04-29 09:02:42 +00:00
|
|
|
return parse(xml).then(function() {
|
2015-07-20 15:13:47 +00:00
|
|
|
|
2020-04-16 05:49:59 +00:00
|
|
|
// then
|
2015-07-20 15:13:47 +00:00
|
|
|
// parsing a XML document should not take too long
|
|
|
|
expect((new Date().getTime() - start)).to.be.below(1000);
|
2014-09-08 17:04:07 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2020-04-16 05:49:59 +00:00
|
|
|
});
|