Open menus in buttongroups at different positions
Change-Id: Ica00912ebbd670680dadb65e3480342572895701
diff --git a/dev/js/spec/buttongroupSpec.js b/dev/js/spec/buttongroupSpec.js
index c92832e..258d847 100644
--- a/dev/js/spec/buttongroupSpec.js
+++ b/dev/js/spec/buttongroupSpec.js
@@ -1,4 +1,4 @@
-define(['buttongroup','state'], function (buttonGroupClass, stateClass) {
+define(['buttongroup','buttongroup/menu','menu/item','state'], function (buttonGroupClass, buttonGroupMenuClass, defaultItemClass, stateClass) {
var FunObj = {
count : 0,
@@ -285,4 +285,46 @@
expect(btn.tagName).toEqual('C3');
});
});
+
+ describe('KorAP.ButtonGroup.Menu', function () {
+ it('should reposition', function () {
+ const menu = buttonGroupMenuClass.create([["hallo", undefined, function () {}]], defaultItemClass);
+ const div = document.createElement('div');
+
+ document.body.appendChild(div);
+
+ div.style.position = 'absolute';
+ div.style.display = 'block';
+ div.style.left = '14px';
+ div.style.top = '20px';
+ div.style.width = '40px';
+ div.style.height = '30px';
+
+ menu.show();
+
+ // 000
+ menu._repos(div);
+ let elem = menu.element();
+ const fffl = elem.style.left;
+ const ffft = elem.style.top;
+
+ // 100
+ menu.openAt(true, false, false);
+ menu._repos(div);
+ elem = menu.element();
+ const tffl = elem.style.left;
+ expect(tffl).not.toEqual(fffl);
+
+
+ // 011
+ menu.openAt(false, true, true);
+ menu._repos(div);
+ elem = menu.element();
+ const fttt = elem.style.top;
+ expect(fttt).not.toEqual(ffft);
+
+ document.body.removeChild(div);
+ document.body.removeChild(elem);
+ });
+ });
});