From 437a28b95361d45f42113c461a9293f87a7bec42 Mon Sep 17 00:00:00 2001 From: Ricardo Matias Date: Fri, 15 May 2015 11:06:49 +0200 Subject: [PATCH] fix(replace): refactor the test case for replace menu positioning --- .../context-pad/ContextPadProviderSpec.js | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/test/spec/features/context-pad/ContextPadProviderSpec.js b/test/spec/features/context-pad/ContextPadProviderSpec.js index 7f3b83fa..8c6b4a97 100644 --- a/test/spec/features/context-pad/ContextPadProviderSpec.js +++ b/test/spec/features/context-pad/ContextPadProviderSpec.js @@ -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); })); + }); });