2014-06-30 15:03:35 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var Matchers = require('../../../Matchers'),
|
|
|
|
TestHelper = require('../../../TestHelper');
|
|
|
|
|
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
|
|
|
|
2014-07-30 14:06:32 +00:00
|
|
|
beforeEach(Matchers.addDeepEquals);
|
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');
|
|
|
|
expect(task).toBeDefined();
|
|
|
|
expect(task.$type).toEqual('bpmn:Task');
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2014-08-11 15:45:47 +00:00
|
|
|
expect(task.$type).toEqual('bpmn:ServiceTask');
|
|
|
|
expect(task.id).toMatch(/^ServiceTask_/g);
|
|
|
|
}));
|
2014-08-12 09:03:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
it('should assign id (with semantic prefix)', inject(function(bpmnFactory) {
|
|
|
|
var plane = bpmnFactory.create('bpmndi:BPMNPlane');
|
|
|
|
|
|
|
|
expect(plane.$type).toEqual('bpmndi:BPMNPlane');
|
|
|
|
expect(plane.id).toMatch(/^BPMNPlane_/g);
|
|
|
|
}));
|
|
|
|
|
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
|
|
|
|
expect(result).toDeepEqual([
|
|
|
|
{ $type: 'dc:Point', x: 0, y: 0 },
|
|
|
|
{ $type: 'dc:Point', x: 0, y: 0 }
|
|
|
|
]);
|
2014-06-30 15:03:35 +00:00
|
|
|
|
2014-08-01 06:32:56 +00:00
|
|
|
// expect original not to have been accidently serialized
|
|
|
|
expect(result[0].$attrs).toEqual({});
|
2014-06-30 15:03:35 +00:00
|
|
|
}));
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|