Add test for opening lists in buttongroups
Change-Id: I60e1dcb31060e2cad43354e976fe12aad52f07ae
diff --git a/dev/js/spec/buttongroupSpec.js b/dev/js/spec/buttongroupSpec.js
index a386c1f..f51d90c 100644
--- a/dev/js/spec/buttongroupSpec.js
+++ b/dev/js/spec/buttongroupSpec.js
@@ -121,7 +121,32 @@
it('should open lists', function () {
+ var group = buttonGroupClass.create();
+ expect(group.element().classList.contains('button-group')).toBeTruthy();
+
+ var list = group.addList('More', ['more']);
+
+ list.readItems([
+ ['cool', 'cool', function () { }],
+ ['very cool', 'veryCool', function () { }]
+ ]);
+
+ var btn = group.element().firstChild;
+ expect(btn.tagName).toEqual('SPAN');
+ expect(btn.classList.contains('more')).toBeTruthy();
+ expect(btn.innerText).toEqual('More');
+
+ expect(list.element().classList.contains('visible')).toBeFalsy();
+ // Click to show menu
+ btn.click();
+
+ expect(list.element().classList.contains('visible')).toBeTruthy();
+
+ expect(list.element().children[1].children[0].innerText).toEqual('cool--');
+ expect(list.element().children[1].children[1].innerText).toEqual('very cool--');
+
+ document.body.removeChild(list.element());
});
it('should support toggle buttons', function () {
diff --git a/dev/js/src/buttongroup.js b/dev/js/src/buttongroup.js
index f7acfb7..b4d7813 100644
--- a/dev/js/src/buttongroup.js
+++ b/dev/js/src/buttongroup.js
@@ -84,6 +84,7 @@
*
* Returns the list object.
*/
+ // TODO: Support icons by switching to a data object (see add())
addList : function (title, classes, itemClass = defaultItemClass) {
var list = treeMenuClass.create([], itemClass);
this.add(title, classes, function (e) {