mirror of
https://github.com/sartography/bpmn-js.git
synced 2025-02-02 12:13:42 +00:00
test(replace-menu): refactor and fix positioning test case
relates to bpmn-io/diagram-js#88
This commit is contained in:
parent
19673a340c
commit
db6cd21205
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
var TestHelper = require('../../../TestHelper');
|
var TestHelper = require('../../../TestHelper');
|
||||||
|
|
||||||
|
var domQuery = require('min-dom/lib/query');
|
||||||
|
|
||||||
/* global bootstrapViewer, inject */
|
/* global bootstrapViewer, inject */
|
||||||
|
|
||||||
|
|
||||||
@ -30,40 +32,37 @@ describe('features - context-pad', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe('should show chooser/replace menu in the correct position ', function() {
|
describe('should show replace popup menu in the correct position ', function() {
|
||||||
|
|
||||||
var container;
|
var container;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
container = jasmine.getEnv().getTestContainer();
|
container = jasmine.getEnv().getTestContainer();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('for a diagram element', inject(function(elementRegistry, contextPad, popupMenu) {
|
||||||
|
|
||||||
it('for a diagram element', inject(function(elementRegistry, eventBus, contextPad, popupMenu) {
|
|
||||||
// given
|
// given
|
||||||
var bpmnContainer = container.firstChild,
|
var element = elementRegistry.get('StartEvent_1'),
|
||||||
element = elementRegistry.get('StartEvent_1'),
|
|
||||||
padding = 5,
|
padding = 5,
|
||||||
replaceMenuRect,
|
replaceMenuRect,
|
||||||
padMenuRect;
|
padMenuRect;
|
||||||
|
|
||||||
bpmnContainer.style.marginLeft = '200px';
|
contextPad.open(element);
|
||||||
bpmnContainer.style.marginTop = '200px';
|
padMenuRect = contextPad.getPad(element).html.getBoundingClientRect();
|
||||||
|
|
||||||
|
// mock event
|
||||||
|
var event = {
|
||||||
|
target: domQuery('[data-action="replace"]', container),
|
||||||
|
preventDefault: function(){}
|
||||||
|
};
|
||||||
|
|
||||||
// when
|
// when
|
||||||
eventBus.on('contextPad.open', function(event) {
|
contextPad.trigger('click', event);
|
||||||
event.current.entries.replace.action.click(null, element);
|
replaceMenuRect = domQuery('.replace-menu', container).getBoundingClientRect();
|
||||||
replaceMenuRect = popupMenu._instances['replace-menu']._container.getBoundingClientRect();
|
|
||||||
padMenuRect = contextPad.getPad(element).html.getBoundingClientRect();
|
|
||||||
});
|
|
||||||
|
|
||||||
eventBus.fire('element.click', { element: element });
|
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(replaceMenuRect.left).not.toBeGreaterThan(padMenuRect.left);
|
expect(replaceMenuRect.left).not.toBeGreaterThan(padMenuRect.left);
|
||||||
expect(replaceMenuRect.top).not.toBeGreaterThan(padMenuRect.bottom + padding);
|
expect(replaceMenuRect.top).not.toBeGreaterThan(padMenuRect.bottom + padding);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user