2014-06-30 15:03:35 +00:00
|
|
|
'use strict';
|
|
|
|
|
2015-07-15 15:22:19 +00:00
|
|
|
var TestHelper = require('../../../TestHelper');
|
2014-06-30 15:03:35 +00:00
|
|
|
|
2014-08-05 06:17:22 +00:00
|
|
|
/* global bootstrapModeler, inject */
|
2014-06-30 15:03:35 +00:00
|
|
|
|
|
|
|
|
2014-10-30 11:06:43 +00:00
|
|
|
var modelingModule = require('../../../../lib/features/modeling'),
|
|
|
|
coreModule = require('../../../../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-07-15 15:22:19 +00:00
|
|
|
expect(task).to.be.defined;
|
|
|
|
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
|
|
|
}));
|
|
|
|
|
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([
|
|
|
|
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
|
|
|
});
|