2014-06-27 17:52:34 +02:00
|
|
|
'use strict';
|
|
|
|
|
2015-03-31 14:17:15 +02:00
|
|
|
var TestHelper = require('../../../TestHelper');
|
2014-06-27 17:52:34 +02:00
|
|
|
|
2015-07-15 17:22:19 +02:00
|
|
|
var TestContainer = require('mocha-test-container-support');
|
|
|
|
|
2015-06-04 15:24:35 +02:00
|
|
|
var domQuery = require('min-dom/lib/query');
|
|
|
|
|
2014-08-05 08:17:22 +02:00
|
|
|
/* global bootstrapViewer, inject */
|
2014-06-27 17:52:34 +02:00
|
|
|
|
|
|
|
|
2014-08-01 07:16:59 +02:00
|
|
|
var contextPadModule = require('../../../../lib/features/context-pad'),
|
2015-04-30 10:52:34 +02:00
|
|
|
coreModule = require('../../../../lib/core'),
|
|
|
|
modelingModule = require('../../../../lib/features/modeling'),
|
2015-02-05 16:00:05 +01:00
|
|
|
popupModule = require('diagram-js/lib/features/popup-menu'),
|
|
|
|
replaceModule = require('diagram-js/lib/features/replace');
|
2014-06-27 17:52:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
describe('features - context-pad', function() {
|
|
|
|
|
2015-03-31 14:17:15 +02:00
|
|
|
var diagramXML = require('../../../fixtures/bpmn/simple.bpmn');
|
2014-06-27 17:52:34 +02:00
|
|
|
|
2015-04-30 10:52:34 +02:00
|
|
|
var testModules = [ contextPadModule, coreModule, modelingModule, popupModule, replaceModule ];
|
2014-06-27 17:52:34 +02:00
|
|
|
|
2014-08-05 08:17:22 +02:00
|
|
|
beforeEach(bootstrapViewer(diagramXML, { modules: testModules }));
|
2014-06-27 17:52:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
describe('bootstrap', function() {
|
|
|
|
|
|
|
|
it('should bootstrap', inject(function(contextPadProvider) {
|
2015-07-15 17:22:19 +02:00
|
|
|
expect(contextPadProvider).to.exist;
|
2014-06-27 17:52:34 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
2015-05-08 14:26:05 +02:00
|
|
|
|
|
|
|
|
2015-06-04 15:24:35 +02:00
|
|
|
describe('should show replace popup menu in the correct position ', function() {
|
2015-05-08 14:26:05 +02:00
|
|
|
|
2015-05-15 11:06:49 +02:00
|
|
|
var container;
|
|
|
|
beforeEach(function() {
|
2015-07-15 17:22:19 +02:00
|
|
|
container = TestContainer.get(this);
|
2015-05-15 11:06:49 +02:00
|
|
|
});
|
2015-05-08 14:26:05 +02:00
|
|
|
|
2015-06-04 15:24:35 +02:00
|
|
|
it('for a diagram element', inject(function(elementRegistry, contextPad, popupMenu) {
|
2015-05-15 11:06:49 +02:00
|
|
|
|
2015-05-08 14:26:05 +02:00
|
|
|
// given
|
2015-06-04 15:24:35 +02:00
|
|
|
var element = elementRegistry.get('StartEvent_1'),
|
2015-05-15 11:06:49 +02:00
|
|
|
padding = 5,
|
|
|
|
replaceMenuRect,
|
|
|
|
padMenuRect;
|
2015-07-03 10:48:32 +02:00
|
|
|
|
2015-06-04 15:24:35 +02:00
|
|
|
contextPad.open(element);
|
|
|
|
padMenuRect = contextPad.getPad(element).html.getBoundingClientRect();
|
2015-05-08 14:26:05 +02:00
|
|
|
|
2015-06-04 15:24:35 +02:00
|
|
|
// mock event
|
|
|
|
var event = {
|
|
|
|
target: domQuery('[data-action="replace"]', container),
|
|
|
|
preventDefault: function(){}
|
|
|
|
};
|
2015-05-08 14:26:05 +02:00
|
|
|
|
|
|
|
// when
|
2015-06-04 15:24:35 +02:00
|
|
|
contextPad.trigger('click', event);
|
2015-07-03 10:48:32 +02:00
|
|
|
replaceMenuRect = domQuery('.replace-menu', container).getBoundingClientRect();
|
2015-05-08 14:26:05 +02:00
|
|
|
|
|
|
|
// then
|
2015-07-15 17:22:19 +02:00
|
|
|
expect(replaceMenuRect.left).to.be.at.most(padMenuRect.left);
|
|
|
|
expect(replaceMenuRect.top).to.be.at.most(padMenuRect.bottom + padding);
|
2015-05-08 14:26:05 +02:00
|
|
|
}));
|
|
|
|
});
|
2014-10-27 12:07:57 +01:00
|
|
|
});
|