2016-08-18 07:08:00 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
require('../../../TestHelper');
|
|
|
|
|
|
|
|
/* global bootstrapModeler, inject */
|
|
|
|
|
|
|
|
var pick = require('lodash/object/pick');
|
|
|
|
|
|
|
|
var getBBox = require('diagram-js/lib/util/Elements').getBBox;
|
|
|
|
|
2017-01-09 13:30:39 +00:00
|
|
|
var getParent = require('lib/features/modeling/util/ModelingUtil').getParent;
|
|
|
|
|
2016-08-18 07:08:00 +00:00
|
|
|
|
|
|
|
var bpmnEditorActionsModule = require('../../../../lib/features/editor-actions'),
|
|
|
|
modelingModule = require('../../../../lib/features/modeling'),
|
|
|
|
coreModule = require('../../../../lib/core');
|
|
|
|
|
2017-01-09 13:30:39 +00:00
|
|
|
var basicXML = require('../../../fixtures/bpmn/nested-subprocesses.bpmn'),
|
2016-08-22 15:04:13 +00:00
|
|
|
collaborationXML = require('../../../fixtures/bpmn/collaboration.bpmn');
|
2016-08-18 07:08:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe('features/editor-actions', function() {
|
|
|
|
|
|
|
|
describe('#moveToOrigin', function() {
|
|
|
|
|
|
|
|
function testMoveToOrigin(xml) {
|
|
|
|
|
|
|
|
return function() {
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(xml, { modules: [ bpmnEditorActionsModule, modelingModule, coreModule ] }));
|
|
|
|
|
|
|
|
it('should move to origin', inject(function(editorActions) {
|
|
|
|
// given
|
|
|
|
var elements = editorActions.trigger('selectElements'),
|
|
|
|
boundingBox;
|
|
|
|
|
|
|
|
// when
|
|
|
|
editorActions.trigger('moveToOrigin');
|
|
|
|
|
|
|
|
boundingBox = getBBox(elements);
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(pick(boundingBox, [ 'x', 'y' ])).to.eql({ x: 0, y: 0 });
|
|
|
|
}));
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
describe('single process', testMoveToOrigin(basicXML));
|
|
|
|
|
|
|
|
describe('collaboration', testMoveToOrigin(collaborationXML));
|
|
|
|
|
2017-01-09 13:30:39 +00:00
|
|
|
describe('subprocesses', function() {
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(basicXML, { modules: [ bpmnEditorActionsModule, modelingModule, coreModule ] }));
|
|
|
|
|
|
|
|
it('should ignore children of subprocesses', inject(function(editorActions, elementRegistry) {
|
|
|
|
// given
|
|
|
|
var startEvent = elementRegistry.get('StartEvent_3'),
|
|
|
|
startEventParent = getParent(startEvent);
|
|
|
|
|
|
|
|
// when
|
|
|
|
editorActions.trigger('moveToOrigin');
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(getParent(startEvent)).to.equal(startEventParent);
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
|
2016-08-18 07:08:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|