2014-03-13 15:06:30 +00:00
|
|
|
var fs = require('fs');
|
|
|
|
|
2014-04-03 17:26:00 +00:00
|
|
|
var BpmnModel = require('bpmn-moddle'),
|
2014-04-03 09:47:26 +00:00
|
|
|
Modeler = require('../../../lib/Modeler');
|
2014-03-13 15:06:30 +00:00
|
|
|
|
|
|
|
var Matchers = require('../Matchers');
|
|
|
|
|
2014-04-03 09:47:26 +00:00
|
|
|
describe('Modeler', function() {
|
2014-03-13 15:06:30 +00:00
|
|
|
|
|
|
|
var bpmnModel = BpmnModel.instance();
|
|
|
|
|
|
|
|
function read(xml, opts, callback) {
|
|
|
|
return BpmnModel.fromXML(xml, 'bpmn:Definitions', opts, callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var container;
|
|
|
|
|
2014-03-21 20:10:01 +00:00
|
|
|
|
|
|
|
beforeEach(Matchers.add);
|
|
|
|
|
2014-03-13 15:06:30 +00:00
|
|
|
beforeEach(function() {
|
|
|
|
container = document.createElement('div');
|
|
|
|
document.getElementsByTagName('body')[0].appendChild(container);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function() {
|
|
|
|
container.parentNode.removeChild(container);
|
|
|
|
});
|
|
|
|
|
2014-03-21 20:10:01 +00:00
|
|
|
|
2014-03-13 15:06:30 +00:00
|
|
|
it('should import simple process', function(done) {
|
|
|
|
|
|
|
|
var xml = fs.readFileSync('test/fixtures/bpmn/simple.bpmn', 'utf8');
|
|
|
|
|
2014-04-03 09:47:26 +00:00
|
|
|
var renderer = new Modeler(container);
|
2014-03-13 15:06:30 +00:00
|
|
|
|
2014-03-21 20:10:01 +00:00
|
|
|
renderer.importXML(xml, function(err) {
|
|
|
|
done(err);
|
2014-03-13 15:06:30 +00:00
|
|
|
});
|
|
|
|
});
|
2014-04-03 09:47:26 +00:00
|
|
|
|
|
|
|
|
2014-03-17 10:11:25 +00:00
|
|
|
it('should import empty definitions', function(done) {
|
|
|
|
|
|
|
|
var xml = fs.readFileSync('test/fixtures/bpmn/empty-definitions.bpmn', 'utf8');
|
|
|
|
|
2014-04-03 09:47:26 +00:00
|
|
|
var renderer = new Modeler(container);
|
2014-03-21 20:10:01 +00:00
|
|
|
|
|
|
|
renderer.importXML(xml, function(err) {
|
2014-04-03 09:47:26 +00:00
|
|
|
|
2014-03-21 20:10:01 +00:00
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should handle errors', function(done) {
|
|
|
|
|
|
|
|
var xml = 'invalid stuff';
|
2014-03-17 10:11:25 +00:00
|
|
|
|
2014-04-03 09:47:26 +00:00
|
|
|
var renderer = new Modeler(container);
|
2014-03-21 20:10:01 +00:00
|
|
|
|
|
|
|
renderer.importXML(xml, function(err) {
|
|
|
|
|
|
|
|
expect(err).toBeDefined();
|
|
|
|
|
|
|
|
done();
|
2014-03-17 10:11:25 +00:00
|
|
|
});
|
|
|
|
});
|
2014-03-21 20:10:01 +00:00
|
|
|
|
2014-03-13 15:06:30 +00:00
|
|
|
});
|