2014-03-13 15:06:30 +00:00
|
|
|
var fs = require('fs');
|
|
|
|
|
2014-04-25 11:30:10 +00:00
|
|
|
var Modeler = require('../../../lib/Modeler');
|
2014-03-13 15:06:30 +00:00
|
|
|
|
|
|
|
var Matchers = require('../Matchers');
|
|
|
|
|
|
|
|
|
2014-04-25 11:30:10 +00:00
|
|
|
describe('Modeler', function() {
|
2014-03-13 15:06:30 +00:00
|
|
|
|
2014-04-25 11:30:10 +00:00
|
|
|
beforeEach(Matchers.add);
|
2014-03-13 15:06:30 +00:00
|
|
|
|
|
|
|
var container;
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
container = document.createElement('div');
|
|
|
|
document.getElementsByTagName('body')[0].appendChild(container);
|
|
|
|
});
|
|
|
|
|
2014-03-21 20:10:01 +00:00
|
|
|
|
2014-06-17 09:19:31 +00:00
|
|
|
function createModeler(xml, done) {
|
|
|
|
var modeler = new Modeler({ container: container });
|
|
|
|
|
|
|
|
modeler.importXML(xml, function(err) {
|
|
|
|
done(err, modeler);
|
|
|
|
});
|
|
|
|
}
|
2014-03-13 15:06:30 +00:00
|
|
|
|
2014-06-17 09:19:31 +00:00
|
|
|
it('should import simple process', function(done) {
|
2014-03-13 15:06:30 +00:00
|
|
|
var xml = fs.readFileSync('test/fixtures/bpmn/simple.bpmn', 'utf8');
|
2014-06-17 09:19:31 +00:00
|
|
|
createModeler(xml, done);
|
|
|
|
});
|
2014-03-13 15:06:30 +00:00
|
|
|
|
|
|
|
|
2014-06-17 09:19:31 +00:00
|
|
|
it('should import empty definitions', function(done) {
|
|
|
|
var xml = fs.readFileSync('test/fixtures/bpmn/empty-definitions.bpmn', 'utf8');
|
|
|
|
createModeler(xml, done);
|
2014-03-13 15:06:30 +00:00
|
|
|
});
|
2014-04-25 11:30:10 +00:00
|
|
|
|
|
|
|
|
2014-06-17 09:19:31 +00:00
|
|
|
it('should handle errors', function(done) {
|
2014-03-17 10:11:25 +00:00
|
|
|
|
2014-06-17 09:19:31 +00:00
|
|
|
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) {
|
2014-04-03 09:47:26 +00:00
|
|
|
|
2014-06-17 09:19:31 +00:00
|
|
|
expect(err).toBeDefined();
|
|
|
|
|
|
|
|
done();
|
2014-03-21 20:10:01 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2014-06-17 09:19:31 +00:00
|
|
|
describe('dependency injection', function() {
|
2014-03-21 20:10:01 +00:00
|
|
|
|
2014-06-17 09:19:31 +00:00
|
|
|
it('should be available via di as <bpmnjs>', function(done) {
|
2014-03-17 10:11:25 +00:00
|
|
|
|
2014-06-17 09:19:31 +00:00
|
|
|
debugger;
|
2014-03-21 20:10:01 +00:00
|
|
|
|
2014-06-17 09:19:31 +00:00
|
|
|
var xml = fs.readFileSync('test/fixtures/bpmn/simple.bpmn', 'utf8');
|
2014-03-21 20:10:01 +00:00
|
|
|
|
2014-06-17 09:19:31 +00:00
|
|
|
createModeler(xml, function(err, modeler) {
|
2014-03-21 20:10:01 +00:00
|
|
|
|
2014-06-17 09:19:31 +00:00
|
|
|
expect(modeler.get('bpmnjs')).toBe(modeler);
|
|
|
|
done(err);
|
|
|
|
});
|
2014-03-17 10:11:25 +00:00
|
|
|
});
|
2014-06-17 09:19:31 +00:00
|
|
|
|
2014-03-17 10:11:25 +00:00
|
|
|
});
|
2014-03-21 20:10:01 +00:00
|
|
|
|
2014-03-13 15:06:30 +00:00
|
|
|
});
|