fix(replace): refactor the test case for replace menu positioning

This commit is contained in:
Ricardo Matias 2015-05-15 11:06:49 +02:00
parent 206457e764
commit 437a28b953
1 changed files with 18 additions and 11 deletions

View File

@ -32,17 +32,23 @@ describe('features - context-pad', function() {
describe('should show chooser/replace menu in the correct position ', function() {
var container;
beforeEach(function() {
container = jasmine.getEnv().getTestContainer();
});
it('for a diagram element', inject(function(elementRegistry, eventBus, contextPad, popupMenu) {
// given
var text = document.createElement("SPAN");
text.innerText = "Pushing the canvas a bit to the right";
document.body.insertBefore(text, document.body.firstChild);
TestHelper.insertCSS('diagram.css', 'div[class=test-container]{display: inline-block;}');
var bpmnContainer = container.firstChild,
element = elementRegistry.get('StartEvent_1'),
padding = 5,
replaceMenuRect,
padMenuRect;
var element = elementRegistry.get('StartEvent_1');
var replaceMenuRect;
var padMenuRect;
bpmnContainer.style.marginLeft = '200px';
bpmnContainer.style.marginTop = '200px';
// when
eventBus.on('contextPad.open', function(event) {
@ -50,13 +56,14 @@ describe('features - context-pad', function() {
replaceMenuRect = popupMenu._instances['replace-menu']._container.getBoundingClientRect();
padMenuRect = contextPad.getPad(element).html.getBoundingClientRect();
});
eventBus.fire('element.click', { element: element });
// then
expect(replaceMenuRect.left).not.
toBeGreaterThan(padMenuRect.left);
expect(replaceMenuRect.left).not.toBeGreaterThan(padMenuRect.left);
expect(replaceMenuRect.top).not.toBeGreaterThan(padMenuRect.bottom + padding);
}));
});
});