Introduce pagination panel (fixes #141)
Change-Id: Ib8522c4d154b96630abcd23c7115b2fb4633bdfb
diff --git a/dev/js/spec/buttongroupSpec.js b/dev/js/spec/buttongroupSpec.js
index 07183f2..d35abfe 100644
--- a/dev/js/spec/buttongroupSpec.js
+++ b/dev/js/spec/buttongroupSpec.js
@@ -123,7 +123,8 @@
var group = buttonGroupClass.create();
expect(group.element().classList.contains('button-group')).toBeTruthy();
- var list = group.addList('More', {'cls':['more']});
+ var b = group.addList('More', {'cls':['more']});
+ var list = b.list;
list.readItems([
['cool', 'cool', function () { }],
@@ -152,7 +153,8 @@
var group = buttonGroupClass.create();
expect(group.element().classList.contains('button-group')).toBeTruthy();
- var list = group.addList('More', {'cls':['more']});
+ var b = group.addList('More', {'cls':['more']});
+ var list = b.list;
let x = 'empty';
list.add('Meta1', {'cls':['meta'], 'icon': 'metaicon'}, function (e) {
diff --git a/dev/js/spec/panelSpec.js b/dev/js/spec/panelSpec.js
index 8618369..e53c464 100644
--- a/dev/js/spec/panelSpec.js
+++ b/dev/js/spec/panelSpec.js
@@ -1,4 +1,4 @@
-define(['panel','view','panel/result','util'], function (panelClass,viewClass, resultClass) {
+define(['panel','view','panel/result','panel/pagination','util'], function (panelClass,viewClass,resultClass,paginationClass) {
var controlStr = "";
@@ -186,4 +186,40 @@
document.body.removeChild(div);
});
});
+
+ describe('KorAP.Panel.Pagination', function () {
+ it('should be initializable', function () {
+ // Create pagination element for pagination information
+ let p = document.createElement('div');
+ p.setAttribute('id', 'pagination')
+ p.setAttribute('data-page',3);
+ p.setAttribute('data-total',30);
+ p.setAttribute('data-count',25);
+
+ document.body.appendChild(p);
+
+ // Create pagination class object
+ var pagination = paginationClass.create();
+ let list = pagination.actions().element();
+ expect(list.classList.contains('button-group-list')).toBeTruthy();
+ expect(list.classList.contains('visible')).toBeFalsy();
+
+ pagination.addRandomPage();
+
+ let clicked = false;
+ pagination.actions().add(
+ "test", {}, function () { clicked = true }
+ );
+
+ pagination.buttonGroup().element().firstChild.click();
+ expect(list.classList.contains('visible')).toBeTruthy();
+
+ expect(clicked).toBeFalsy();
+ pagination.actions().element().children[4].click();
+ expect(clicked).toBeTruthy();
+
+ document.body.removeChild(p);
+ document.body.removeChild(pagination.actions().element());
+ });
+ });
});