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-03-21 13:42:14 +00:00
|
|
|
Viewer = require('../../../lib/Viewer');
|
2014-03-13 15:06:30 +00:00
|
|
|
|
|
|
|
var Matchers = require('../Matchers');
|
|
|
|
|
2014-04-03 09:47:26 +00:00
|
|
|
describe('Viewer', 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-03-21 20:10:01 +00:00
|
|
|
var renderer = new Viewer(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-03-17 10:11:25 +00:00
|
|
|
|
2014-03-21 20:10:01 +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-03-21 20:10:01 +00:00
|
|
|
var renderer = new Viewer(container);
|
|
|
|
|
|
|
|
renderer.importXML(xml, function(err) {
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should handle errors', function(done) {
|
|
|
|
|
|
|
|
var xml = 'invalid stuff';
|
2014-03-17 10:11:25 +00:00
|
|
|
|
2014-03-21 20:10:01 +00:00
|
|
|
var renderer = new Viewer(container);
|
|
|
|
|
|
|
|
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
|
|
|
});
|