2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
bootstrapModeler,
|
|
|
|
inject
|
|
|
|
} from 'test/TestHelper';
|
2014-06-30 15:03:35 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import modelingModule from 'lib/features/modeling';
|
|
|
|
import coreModule from 'lib/core';
|
2014-06-30 15:03:35 +00:00
|
|
|
|
|
|
|
|
2014-08-01 06:32:56 +00:00
|
|
|
describe('features - bpmn-factory', function() {
|
2014-06-30 15:03:35 +00:00
|
|
|
|
2015-03-31 12:17:15 +00:00
|
|
|
var diagramXML = require('../../../fixtures/bpmn/simple.bpmn');
|
2014-06-30 15:03:35 +00:00
|
|
|
|
2014-10-30 11:06:43 +00:00
|
|
|
var testModules = [ modelingModule, coreModule ];
|
2014-06-30 15:03:35 +00:00
|
|
|
|
2014-08-05 06:17:22 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
2014-06-30 15:03:35 +00:00
|
|
|
|
2014-08-12 09:03:11 +00:00
|
|
|
|
2014-08-11 15:45:47 +00:00
|
|
|
describe('create element', function() {
|
|
|
|
|
2014-08-12 09:03:11 +00:00
|
|
|
it('should return instance', inject(function(bpmnFactory) {
|
|
|
|
|
|
|
|
var task = bpmnFactory.create('bpmn:Task');
|
2015-12-01 07:27:45 +00:00
|
|
|
expect(task).to.exist;
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(task.$type).to.equal('bpmn:Task');
|
2014-08-12 09:03:11 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should assign id (with semantic prefix)', inject(function(bpmnFactory) {
|
2014-08-11 15:45:47 +00:00
|
|
|
var task = bpmnFactory.create('bpmn:ServiceTask');
|
2014-08-12 09:03:11 +00:00
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(task.$type).to.equal('bpmn:ServiceTask');
|
|
|
|
expect(task.id).to.match(/^ServiceTask_/g);
|
2014-08-11 15:45:47 +00:00
|
|
|
}));
|
2014-08-12 09:03:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should assign id (with semantic prefix)', inject(function(bpmnFactory) {
|
|
|
|
var plane = bpmnFactory.create('bpmndi:BPMNPlane');
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(plane.$type).to.equal('bpmndi:BPMNPlane');
|
|
|
|
expect(plane.id).to.match(/^BPMNPlane_/g);
|
2014-08-12 09:03:11 +00:00
|
|
|
}));
|
|
|
|
|
2018-05-28 07:53:52 +00:00
|
|
|
|
|
|
|
it('should assign bpmn:LaneSet id', inject(function(bpmnFactory) {
|
|
|
|
var set = bpmnFactory.create('bpmn:LaneSet');
|
|
|
|
|
|
|
|
expect(set.id).to.exist;
|
|
|
|
}));
|
|
|
|
|
2014-08-11 15:45:47 +00:00
|
|
|
});
|
|
|
|
|
2014-06-30 15:03:35 +00:00
|
|
|
|
2014-08-01 06:32:56 +00:00
|
|
|
describe('create di', function() {
|
2014-06-30 15:03:35 +00:00
|
|
|
|
2014-08-01 06:32:56 +00:00
|
|
|
it('should create waypoints', inject(function(bpmnFactory) {
|
2014-06-30 15:03:35 +00:00
|
|
|
|
2014-08-01 06:32:56 +00:00
|
|
|
// given
|
|
|
|
var waypoints = [
|
|
|
|
{ original: { x: 0, y: 0 }, x: 0, y: 0 },
|
|
|
|
{ original: { x: 0, y: 0 }, x: 0, y: 0 }
|
|
|
|
];
|
2014-06-30 15:03:35 +00:00
|
|
|
|
2014-08-01 06:32:56 +00:00
|
|
|
// when
|
|
|
|
var result = bpmnFactory.createDiWaypoints(waypoints);
|
2014-06-30 15:03:35 +00:00
|
|
|
|
2014-08-01 06:32:56 +00:00
|
|
|
// then
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(result).eql([
|
2016-06-07 06:46:45 +00:00
|
|
|
bpmnFactory.create('dc:Point', { x: 0, y: 0 }),
|
|
|
|
bpmnFactory.create('dc:Point', { x: 0, y: 0 })
|
2014-08-01 06:32:56 +00:00
|
|
|
]);
|
2014-06-30 15:03:35 +00:00
|
|
|
|
2014-08-01 06:32:56 +00:00
|
|
|
// expect original not to have been accidently serialized
|
2015-07-15 15:22:19 +00:00
|
|
|
expect(result[0].$attrs).to.eql({});
|
2014-06-30 15:03:35 +00:00
|
|
|
}));
|
|
|
|
});
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
});
|