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

View File

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