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