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
|
|
|
|
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) {
|
|
|
|
expect(contextPadProvider).toBeDefined();
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
2015-05-08 12:26:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
describe('should show chooser/replace menu in the correct position ', function() {
|
|
|
|
|
2015-05-15 09:06:49 +00:00
|
|
|
var container;
|
|
|
|
|
|
|
|
beforeEach(function() {
|
|
|
|
container = jasmine.getEnv().getTestContainer();
|
|
|
|
});
|
2015-05-08 12:26:05 +00:00
|
|
|
|
2015-05-15 09:06:49 +00:00
|
|
|
|
|
|
|
it('for a diagram element', inject(function(elementRegistry, eventBus, contextPad, popupMenu) {
|
2015-05-08 12:26:05 +00:00
|
|
|
// given
|
2015-05-15 09:06:49 +00:00
|
|
|
var bpmnContainer = container.firstChild,
|
|
|
|
element = elementRegistry.get('StartEvent_1'),
|
|
|
|
padding = 5,
|
|
|
|
replaceMenuRect,
|
|
|
|
padMenuRect;
|
2015-05-08 12:26:05 +00:00
|
|
|
|
2015-05-15 09:06:49 +00:00
|
|
|
bpmnContainer.style.marginLeft = '200px';
|
|
|
|
bpmnContainer.style.marginTop = '200px';
|
2015-05-08 12:26:05 +00:00
|
|
|
|
|
|
|
// when
|
|
|
|
eventBus.on('contextPad.open', function(event) {
|
|
|
|
event.current.entries.replace.action.click(null, element);
|
|
|
|
replaceMenuRect = popupMenu._instances['replace-menu']._container.getBoundingClientRect();
|
|
|
|
padMenuRect = contextPad.getPad(element).html.getBoundingClientRect();
|
|
|
|
});
|
|
|
|
|
2015-05-15 09:06:49 +00:00
|
|
|
eventBus.fire('element.click', { element: element });
|
2015-05-08 12:26:05 +00:00
|
|
|
|
|
|
|
// then
|
2015-05-15 09:06:49 +00:00
|
|
|
expect(replaceMenuRect.left).not.toBeGreaterThan(padMenuRect.left);
|
|
|
|
expect(replaceMenuRect.top).not.toBeGreaterThan(padMenuRect.bottom + padding);
|
2015-05-08 12:26:05 +00:00
|
|
|
}));
|
2015-05-15 09:06:49 +00:00
|
|
|
|
2015-05-08 12:26:05 +00:00
|
|
|
});
|
|
|
|
|
2014-10-27 11:07:57 +00:00
|
|
|
});
|