chore(tests): use jasmine-test-container-support for test execution

This allows us to have tests nice and easily rendered within test-local
containers, including captions, status highlighting and links.
This commit is contained in:
Nico Rehwaldt 2014-06-18 11:45:30 +02:00
parent 84510cc45d
commit dc3fca67b1
11 changed files with 131 additions and 325 deletions

View File

@ -40,6 +40,7 @@
"grunt-jsdoc": "~0.5.1", "grunt-jsdoc": "~0.5.1",
"grunt-karma": "~0.8.0", "grunt-karma": "~0.8.0",
"grunt-release": "~0.7.0", "grunt-release": "~0.7.0",
"jasmine-test-container-support": "0.0.1",
"jsondiffpatch": "^0.1.7", "jsondiffpatch": "^0.1.7",
"karma": "^0.12.12", "karma": "^0.12.12",
"karma-bro": "~0.2.0", "karma-bro": "~0.2.0",

View File

@ -3,6 +3,10 @@
var _ = require('lodash'); var _ = require('lodash');
var BpmnJS = require('../../'); var BpmnJS = require('../../');
// enhance jasmine with test container API
require('jasmine-test-container-support').extend(jasmine);
var OPTIONS, BPMN_JS; var OPTIONS, BPMN_JS;
function options(opts) { function options(opts) {
@ -40,11 +44,13 @@ function bootstrapBpmnJS(diagram, options, locals) {
return function(done) { return function(done) {
var testContainer = jasmine.getEnv().getTestContainer();
var _diagram = diagram, var _diagram = diagram,
_options = options, _options = options,
_locals = locals; _locals = locals;
if (!_locals && _.isFunction(_options)) { if (_locals === undefined && _.isFunction(_options)) {
_locals = _options; _locals = _options;
_options = null; _options = null;
} }
@ -57,15 +63,23 @@ function bootstrapBpmnJS(diagram, options, locals) {
_locals = _locals(); _locals = _locals();
} }
_options = _.extend({}, OPTIONS || {}, _options || {}); _options = _.extend({ container: testContainer }, OPTIONS || {}, _options || {});
var mockModule = {}; if (_locals) {
var mockModule = {};
_.forEach(_locals, function(v, k) { _.forEach(_locals, function(v, k) {
mockModule[k] = ['value', v]; mockModule[k] = ['value', v];
}); });
_options.modules = _.unique([].concat(_options.modules || [], [ mockModule ])); _options.modules = [].concat(_options.modules || [], [ mockModule ]);
}
_options.modules = _.unique(_options.modules);
if (_options.modules.length == 0) {
_options.modules = undefined;
}
BPMN_JS = new BpmnJS(_options); BPMN_JS = new BpmnJS(_options);

View File

@ -1,19 +1,25 @@
'use strict';
var Matchers = require('../Matchers'),
TestHelper = require('../TestHelper');
/* global bootstrapBpmnJS, inject */
var fs = require('fs'); var fs = require('fs');
var Modeler = require('../../../lib/Modeler'); var Modeler = require('../../../lib/Modeler');
var Matchers = require('../Matchers');
describe('modeler', function() {
describe('Modeler', function() {
beforeEach(Matchers.add); beforeEach(Matchers.add);
var container; var container;
beforeEach(function() { beforeEach(function() {
container = document.createElement('div'); container = jasmine.getEnv().getTestContainer();
document.getElementsByTagName('body')[0].appendChild(container);
}); });
@ -25,6 +31,7 @@ describe('Modeler', function() {
}); });
} }
it('should import simple process', function(done) { it('should import simple process', function(done) {
var xml = fs.readFileSync('test/fixtures/bpmn/simple.bpmn', 'utf8'); var xml = fs.readFileSync('test/fixtures/bpmn/simple.bpmn', 'utf8');
createModeler(xml, done); createModeler(xml, done);
@ -41,7 +48,7 @@ describe('Modeler', function() {
var xml = 'invalid stuff'; var xml = 'invalid stuff';
var renderer = new Modeler(container); var renderer = new Modeler({ container: container });
renderer.importXML(xml, function(err) { renderer.importXML(xml, function(err) {
@ -56,8 +63,6 @@ describe('Modeler', function() {
it('should be available via di as <bpmnjs>', function(done) { it('should be available via di as <bpmnjs>', function(done) {
debugger;
var xml = fs.readFileSync('test/fixtures/bpmn/simple.bpmn', 'utf8'); var xml = fs.readFileSync('test/fixtures/bpmn/simple.bpmn', 'utf8');
createModeler(xml, function(err, modeler) { createModeler(xml, function(err, modeler) {

View File

@ -1,23 +1,28 @@
'use strict'; 'use strict';
var Matchers = require('../Matchers'),
TestHelper = require('../TestHelper');
/* global bootstrapBpmnJS, inject */
var fs = require('fs'); var fs = require('fs');
var Viewer = require('../../../lib/Viewer'); var Viewer = require('../../../lib/Viewer');
var Matchers = require('../Matchers');
describe('viewer', function() {
describe('Viewer', function() {
beforeEach(Matchers.add); beforeEach(Matchers.add);
var container; var container;
beforeEach(function() { beforeEach(function() {
container = document.createElement('div'); container = jasmine.getEnv().getTestContainer();
document.getElementsByTagName('body')[0].appendChild(container);
}); });
function createViewer(xml, done) { function createViewer(xml, done) {
var renderer = new Viewer({ container: container }); var renderer = new Viewer({ container: container });

View File

@ -1,249 +1,130 @@
'use strict'; 'use strict';
var Matchers = require('../../Matchers'),
TestHelper = require('../../TestHelper');
/* global bootstrapBpmnJS, inject */
var fs = require('fs'); var fs = require('fs');
var Viewer = require('../../../../lib/Viewer');
var Matchers = require('../../Matchers'); describe('draw - bpmn renderer', function() {
describe('draw/BpmnRenderer', function() {
beforeEach(Matchers.add); beforeEach(Matchers.add);
var container;
beforeEach(function() {
container = document.createElement('div');
document.getElementsByTagName('body')[0].appendChild(container);
});
it('should render activity markers', function(done) { it('should render activity markers', function(done) {
var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/activity-markers.bpmn', 'utf8'); var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/activity-markers.bpmn', 'utf8');
bootstrapBpmnJS(xml)(done);
var renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
done(err);
});
}); });
it('should render activity markers (combination)', function(done) { it('should render activity markers (combination)', function(done) {
var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/activity-markers-combination.bpmn', 'utf8'); var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/activity-markers-combination.bpmn', 'utf8');
bootstrapBpmnJS(xml)(done);
var renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
done(err);
});
}); });
it('should render conditional flows', function(done) { it('should render conditional flows', function(done) {
var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/conditional-flow.bpmn', 'utf8'); var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/conditional-flow.bpmn', 'utf8');
bootstrapBpmnJS(xml)(done);
var renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
done(err);
});
}); });
it('should render conditional default flows', function(done) { it('should render conditional default flows', function(done) {
var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/conditional-flow-default.bpmn', 'utf8'); var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/conditional-flow-default.bpmn', 'utf8');
bootstrapBpmnJS(xml)(done);
var renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
done(err);
});
}); });
it('should render NO conditional flow (gateway)', function(done) { it('should render NO conditional flow (gateway)', function(done) {
var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/conditional-flow-gateways.bpmn', 'utf8'); var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/conditional-flow-gateways.bpmn', 'utf8');
bootstrapBpmnJS(xml)(done);
var renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
done(err);
});
}); });
it('should render conditional flow (typed task)', function(done) { it('should render conditional flow (typed task)', function(done) {
var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/conditional-flow-typed-task.bpmn', 'utf8'); var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/conditional-flow-typed-task.bpmn', 'utf8');
bootstrapBpmnJS(xml)(done);
var renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
done(err);
});
}); });
it('should render data objects', function(done) { it('should render data objects', function(done) {
var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/data-objects.bpmn', 'utf8'); var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/data-objects.bpmn', 'utf8');
bootstrapBpmnJS(xml)(done);
var renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
done(err);
});
}); });
it('should render events', function(done) { it('should render events', function(done) {
var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/events.bpmn', 'utf8'); var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/events.bpmn', 'utf8');
bootstrapBpmnJS(xml)(done);
var renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
done(err);
});
}); });
it('should render events (interrupting)', function(done) { it('should render events (interrupting)', function(done) {
var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/events-interrupting.bpmn', 'utf8'); var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/events-interrupting.bpmn', 'utf8');
bootstrapBpmnJS(xml)(done);
var renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
done(err);
});
}); });
it('should render event subprocesses (collapsed)', function(done) { it('should render event subprocesses (collapsed)', function(done) {
var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/event-subprocesses-collapsed.bpmn', 'utf8'); var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/event-subprocesses-collapsed.bpmn', 'utf8');
bootstrapBpmnJS(xml)(done);
var renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
done(err);
});
}); });
it('should render event subprocesses (expanded)', function(done) { it('should render event subprocesses (expanded)', function(done) {
var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/event-subprocesses-expanded.bpmn', 'utf8'); var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/event-subprocesses-expanded.bpmn', 'utf8');
bootstrapBpmnJS(xml)(done);
var renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
done(err);
});
}); });
it('should render gateways', function(done) { it('should render gateways', function(done) {
var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/gateways.bpmn', 'utf8'); var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/gateways.bpmn', 'utf8');
bootstrapBpmnJS(xml)(done);
var renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
done(err);
});
}); });
it('should render group', function(done) { it('should render group', function(done) {
var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/group.bpmn', 'utf8'); var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/group.bpmn', 'utf8');
bootstrapBpmnJS(xml)(done);
var renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
done(err);
});
}); });
it('should render message marker', function(done) { it('should render message marker', function(done) {
var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/message-marker.bpmn', 'utf8'); var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/message-marker.bpmn', 'utf8');
bootstrapBpmnJS(xml)(done);
var renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
done(err);
});
}); });
it('should render pools', function(done) { it('should render pools', function(done) {
var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/pools.bpmn', 'utf8'); var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/pools.bpmn', 'utf8');
bootstrapBpmnJS(xml)(done);
var renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
done(err);
});
}); });
it('should render pool collection marker', function(done) { it('should render pool collection marker', function(done) {
var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/pools-with-collection-marker.bpmn', 'utf8'); var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/pools-with-collection-marker.bpmn', 'utf8');
bootstrapBpmnJS(xml)(done);
var renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
done(err);
});
}); });
it('should render task types', function(done) { it('should render task types', function(done) {
var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/task-types.bpmn', 'utf8'); var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/task-types.bpmn', 'utf8');
bootstrapBpmnJS(xml)(done);
var renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
done(err);
});
}); });
it('should render text annotations', function(done) { it('should render text annotations', function(done) {
var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/text-annotation.bpmn', 'utf8'); var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/draw/text-annotation.bpmn', 'utf8');
bootstrapBpmnJS(xml)(done);
var renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
done(err);
});
}); });
it('should render flow markers', function(done) { it('should render flow markers', function(done) {
var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/flow-markers.bpmn', 'utf8'); var xml = fs.readFileSync(__dirname + '/../../../fixtures/bpmn/flow-markers.bpmn', 'utf8');
bootstrapBpmnJS(xml)(done);
var renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
done(err);
});
}); });
}); });

View File

@ -9,7 +9,7 @@ var fs = require('fs');
var Events = require('diagram-js/lib/core/EventBus'); var Events = require('diagram-js/lib/core/EventBus');
describe('environment/Mocking', function() { describe('environment - mocking', function() {
var diagramXML = fs.readFileSync('test/fixtures/bpmn/simple.bpmn', 'utf8'); var diagramXML = fs.readFileSync('test/fixtures/bpmn/simple.bpmn', 'utf8');

View File

@ -1,15 +1,15 @@
'use strict'; 'use strict';
var TestHelper = require('../../../TestHelper'); var Matchers = require('../../../Matchers'),
TestHelper = require('../../../TestHelper');
/* global bootstrapBpmnJS, inject */ /* global bootstrapBpmnJS, inject */
var fs = require('fs'); var fs = require('fs');
var $ = require('jquery'); var $ = require('jquery');
var Matchers = require('../../../Matchers');
var labelEditingModule = require('../../../../../lib/features/label-editing'); var labelEditingModule = require('../../../../../lib/features/label-editing');
@ -17,24 +17,16 @@ var labelEditingModule = require('../../../../../lib/features/label-editing');
var LabelUtil = require('../../../../../lib/features/label-editing/LabelUtil'); var LabelUtil = require('../../../../../lib/features/label-editing/LabelUtil');
describe('features/label-editing', function() { describe('features - label-editing', function() {
beforeEach(Matchers.add); beforeEach(Matchers.add);
var container;
beforeEach(function() {
container = document.createElement('div');
document.getElementsByTagName('body')[0].appendChild(container);
});
var diagramXML = fs.readFileSync('test/fixtures/bpmn/features/label-editing/labels.bpmn', 'utf-8'); var diagramXML = fs.readFileSync('test/fixtures/bpmn/features/label-editing/labels.bpmn', 'utf-8');
var testModules = [ labelEditingModule ]; var testModules = [ labelEditingModule ];
beforeEach(bootstrapBpmnJS(diagramXML, { container: container, modules: testModules })); beforeEach(bootstrapBpmnJS(diagramXML, { modules: testModules }));
describe('basics', function() { describe('basics', function() {

View File

@ -1,5 +1,11 @@
'use strict'; 'use strict';
var Matchers = require('../../Matchers'),
TestHelper = require('../../TestHelper');
/* global bootstrapBpmnJS, inject */
var fs = require('fs'); var fs = require('fs');
var Diagram = require('diagram-js/lib/Diagram'), var Diagram = require('diagram-js/lib/Diagram'),
@ -8,10 +14,7 @@ var Diagram = require('diagram-js/lib/Diagram'),
Viewer = require('../../../../lib/Viewer'); Viewer = require('../../../../lib/Viewer');
var Matchers = require('../../Matchers'); describe('import - importer', function() {
describe('import/Importer', function() {
var bpmnModel = BpmnModel.instance(); var bpmnModel = BpmnModel.instance();
@ -19,14 +22,13 @@ describe('import/Importer', function() {
return BpmnModel.fromXML(xml, 'bpmn:Definitions', opts, callback); return BpmnModel.fromXML(xml, 'bpmn:Definitions', opts, callback);
} }
var container;
beforeEach(Matchers.add); beforeEach(Matchers.add);
var container;
beforeEach(function() { beforeEach(function() {
container = document.createElement('div'); container = jasmine.getEnv().getTestContainer();
document.getElementsByTagName('body')[0].appendChild(container);
}); });

View File

@ -1,94 +1,54 @@
'use strict'; 'use strict';
var Matchers = require('../../../Matchers'),
TestHelper = require('../../../TestHelper');
/* global bootstrapBpmnJS, inject */
var fs = require('fs'); var fs = require('fs');
var Viewer = require('../../../../../lib/Viewer');
var Matchers = require('../../../Matchers');
describe('import - collapsed container', function() { describe('import - collapsed container', function() {
beforeEach(Matchers.add); beforeEach(Matchers.add);
var loadedXml;
var container, renderer;
function ensureLoaded(xml, done) {
if (xml !== loadedXml) {
// create container
container = document.createElement('div');
document.getElementsByTagName('body')[0].appendChild(container);
renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
if (err) {
done(err);
} else {
loadedXml = xml;
done();
}
});
} else {
done();
}
}
describe('in process', function() { describe('in process', function() {
var diagramXML = fs.readFileSync('test/fixtures/bpmn/import/collapsed.bpmn', 'utf8');
beforeEach(function(done) { beforeEach(bootstrapBpmnJS(diagramXML));
var xml = fs.readFileSync('test/fixtures/bpmn/import/collapsed.bpmn', 'utf8');
ensureLoaded(xml, done);
});
it('should import collapsed subProcess', function() { it('should import collapsed subProcess', inject(function(elementRegistry) {
var elementRegistry = renderer.get('elementRegistry');
var collapsedShape = elementRegistry.getById('SubProcess_1'); var collapsedShape = elementRegistry.getById('SubProcess_1');
var childShape = elementRegistry.getById('IntermediateCatchEvent_1'); var childShape = elementRegistry.getById('IntermediateCatchEvent_1');
expect(collapsedShape.collapsed).toBe(true); expect(collapsedShape.collapsed).toBe(true);
expect(childShape.hidden).toBe(true); expect(childShape.hidden).toBe(true);
}); }));
it('should import collapsed transaction', function() { it('should import collapsed transaction', inject(function(elementRegistry) {
var elementRegistry = renderer.get('elementRegistry');
var collapsedShape = elementRegistry.getById('Transaction_1'); var collapsedShape = elementRegistry.getById('Transaction_1');
var childShape = elementRegistry.getById('UserTask_1'); var childShape = elementRegistry.getById('UserTask_1');
expect(collapsedShape.collapsed).toBe(true); expect(collapsedShape.collapsed).toBe(true);
expect(childShape.hidden).toBe(true); expect(childShape.hidden).toBe(true);
}); }));
it('should import collapsed adhocSubProcess', function() { it('should import collapsed adhocSubProcess', inject(function(elementRegistry) {
var elementRegistry = renderer.get('elementRegistry');
var collapsedShape = elementRegistry.getById('AdHocSubProcess_1'); var collapsedShape = elementRegistry.getById('AdHocSubProcess_1');
var childShape = elementRegistry.getById('StartEvent_1'); var childShape = elementRegistry.getById('StartEvent_1');
expect(collapsedShape.collapsed).toBe(true); expect(collapsedShape.collapsed).toBe(true);
expect(childShape.hidden).toBe(true); expect(childShape.hidden).toBe(true);
}); }));
it('should import collapsed with nested elements', function() { it('should import collapsed with nested elements', inject(function(elementRegistry) {
var elementRegistry = renderer.get('elementRegistry');
var collapsedShape = elementRegistry.getById('SubProcess_4'); var collapsedShape = elementRegistry.getById('SubProcess_4');
var childShape = elementRegistry.getById('SubProcess_5'); var childShape = elementRegistry.getById('SubProcess_5');
var nestedChildShape = elementRegistry.getById('Task_3'); var nestedChildShape = elementRegistry.getById('Task_3');
@ -96,89 +56,70 @@ describe('import - collapsed container', function() {
expect(collapsedShape.collapsed).toBe(true); expect(collapsedShape.collapsed).toBe(true);
expect(childShape.hidden).toBe(true); expect(childShape.hidden).toBe(true);
expect(nestedChildShape.hidden).toBe(true); expect(nestedChildShape.hidden).toBe(true);
}); }));
it('should import collapsed with nested elements', function() { it('should import collapsed with nested elements', inject(function(elementRegistry) {
var elementRegistry = renderer.get('elementRegistry');
var hiddenEventShape = elementRegistry.getById('StartEvent_2'); var hiddenEventShape = elementRegistry.getById('StartEvent_2');
expect(hiddenEventShape.label.hidden).toBe(true); expect(hiddenEventShape.label.hidden).toBe(true);
var hiddenDataShape = elementRegistry.getById('DataObjectReference_1'); var hiddenDataShape = elementRegistry.getById('DataObjectReference_1');
expect(hiddenDataShape.label.hidden).toBe(true); expect(hiddenDataShape.label.hidden).toBe(true);
}); }));
it('should import expanded subProcess', function() { it('should import expanded subProcess', inject(function(elementRegistry) {
var elementRegistry = renderer.get('elementRegistry');
var expandedShape = elementRegistry.getById('SubProcess_3'); var expandedShape = elementRegistry.getById('SubProcess_3');
var childShape = elementRegistry.getById('Task_2'); var childShape = elementRegistry.getById('Task_2');
expect(expandedShape.collapsed).toBe(false); expect(expandedShape.collapsed).toBe(false);
expect(childShape.hidden).toBe(false); expect(childShape.hidden).toBe(false);
}); }));
}); });
describe('in collaboration', function() { describe('in collaboration', function() {
beforeEach(function(done) { var diagramXML = fs.readFileSync('test/fixtures/bpmn/import/collapsed-collaboration.bpmn', 'utf8');
var xml = fs.readFileSync('test/fixtures/bpmn/import/collapsed-collaboration.bpmn', 'utf8');
ensureLoaded(xml, done); beforeEach(bootstrapBpmnJS(diagramXML));
});
it('should import collapsed subProcess in pool', function() { it('should import collapsed subProcess in pool', inject(function(elementRegistry) {
var elementRegistry = renderer.get('elementRegistry');
var expandedShape = elementRegistry.getById('SubProcess_1'); var expandedShape = elementRegistry.getById('SubProcess_1');
var childShape = elementRegistry.getById('Task_1'); var childShape = elementRegistry.getById('Task_1');
expect(expandedShape.collapsed).toBe(true); expect(expandedShape.collapsed).toBe(true);
expect(childShape.hidden).toBe(true); expect(childShape.hidden).toBe(true);
}); }));
it('should import expanded subProcess in pool', function() { it('should import expanded subProcess in pool', inject(function(elementRegistry) {
var elementRegistry = renderer.get('elementRegistry');
var expandedShape = elementRegistry.getById('SubProcess_2'); var expandedShape = elementRegistry.getById('SubProcess_2');
var childShape = elementRegistry.getById('StartEvent_1'); var childShape = elementRegistry.getById('StartEvent_1');
expect(expandedShape.collapsed).toBe(false); expect(expandedShape.collapsed).toBe(false);
expect(childShape.hidden).toBe(false); expect(childShape.hidden).toBe(false);
}); }));
it('should import collapsed subProcess in lane', function() { it('should import collapsed subProcess in lane', inject(function(elementRegistry) {
var elementRegistry = renderer.get('elementRegistry');
var expandedShape = elementRegistry.getById('SubProcess_4'); var expandedShape = elementRegistry.getById('SubProcess_4');
var childShape = elementRegistry.getById('Task_2'); var childShape = elementRegistry.getById('Task_2');
expect(expandedShape.collapsed).toBe(true); expect(expandedShape.collapsed).toBe(true);
expect(childShape.hidden).toBe(true); expect(childShape.hidden).toBe(true);
}); }));
it('should import expanded subProcess in lane', function() { it('should import expanded subProcess in lane', inject(function(elementRegistry) {
var elementRegistry = renderer.get('elementRegistry');
var expandedShape = elementRegistry.getById('SubProcess_3'); var expandedShape = elementRegistry.getById('SubProcess_3');
var childShape = elementRegistry.getById('StartEvent_2'); var childShape = elementRegistry.getById('StartEvent_2');
expect(expandedShape.collapsed).toBe(false); expect(expandedShape.collapsed).toBe(false);
expect(childShape.hidden).toBe(false); expect(childShape.hidden).toBe(false);
}); }));
}); });
}); });

View File

@ -1,59 +1,36 @@
'use strict'; 'use strict';
var Matchers = require('../../../Matchers'),
TestHelper = require('../../../TestHelper');
/* global bootstrapBpmnJS, inject */
var fs = require('fs'); var fs = require('fs');
var Viewer = require('../../../../../lib/Viewer');
var Matchers = require('../../../Matchers');
describe('import - labels', function() { describe('import - labels', function() {
beforeEach(Matchers.add); beforeEach(Matchers.add);
var container;
beforeEach(function() {
container = document.createElement('div');
document.getElementsByTagName('body')[0].appendChild(container);
});
describe('should import embedded labels', function() { describe('should import embedded labels', function() {
it('on flow nodes', function(done) { it('on flow nodes', function(done) {
var xml = fs.readFileSync('test/fixtures/bpmn/import/labels/embedded.bpmn', 'utf8'); var xml = fs.readFileSync('test/fixtures/bpmn/import/labels/embedded.bpmn', 'utf8');
bootstrapBpmnJS(xml)(done);
var renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
done(err);
});
}); });
it('on pools and lanes', function(done) { it('on pools and lanes', function(done) {
var xml = fs.readFileSync('test/fixtures/bpmn/import/labels/collaboration.bpmn', 'utf8'); var xml = fs.readFileSync('test/fixtures/bpmn/import/labels/collaboration.bpmn', 'utf8');
bootstrapBpmnJS(xml)(done);
var renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
done(err);
});
}); });
it('on message flows', function(done) { it('on message flows', function(done) {
var xml = fs.readFileSync('test/fixtures/bpmn/import/labels/collaboration-message-flows.bpmn', 'utf8'); var xml = fs.readFileSync('test/fixtures/bpmn/import/labels/collaboration-message-flows.bpmn', 'utf8');
bootstrapBpmnJS(xml)(done);
var renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
done(err);
});
}); });
}); });
@ -62,26 +39,14 @@ describe('import - labels', function() {
describe('should import external labels', function() { describe('should import external labels', function() {
it('with di', function(done) { it('with di', function(done) {
var xml = fs.readFileSync('test/fixtures/bpmn/import/labels/external.bpmn', 'utf8'); var xml = fs.readFileSync('test/fixtures/bpmn/import/labels/external.bpmn', 'utf8');
bootstrapBpmnJS(xml)(done);
var renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
done(err);
});
}); });
it('without di', function(done) { it('without di', function(done) {
var xml = fs.readFileSync('test/fixtures/bpmn/import/labels/external-no-di.bpmn', 'utf8'); var xml = fs.readFileSync('test/fixtures/bpmn/import/labels/external-no-di.bpmn', 'utf8');
bootstrapBpmnJS(xml)(done);
var renderer = new Viewer(container);
renderer.importXML(xml, function(err) {
done(err);
});
}); });
}); });

View File

@ -1,6 +1,6 @@
var BpmnModel = require('bpmn-moddle'); var BpmnModel = require('bpmn-moddle');
describe('Model - browser support', function() { describe('model - browser support', function() {
function read(xml, callback, done) { function read(xml, callback, done) {