Add pagination info service
Change-Id: I462f05581256575e9b52f474515cb8cb5e533d3b
diff --git a/dev/js/spec/pageInfoSpec.js b/dev/js/spec/pageInfoSpec.js
new file mode 100644
index 0000000..4082bb4
--- /dev/null
+++ b/dev/js/spec/pageInfoSpec.js
@@ -0,0 +1,31 @@
+define(['pageInfo'], function (pageInfoClass) {
+
+ describe('KorAP.PageInfo', function () {
+ it('should be initializable', function () {
+ let pi = pageInfoClass.create();
+ expect(pi.total()).toEqual(0);
+ expect(pi.count()).toEqual(0);
+ expect(pi.page()).toEqual(0);
+ });
+
+ it('should be read the correct values', 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);
+
+ pi = pageInfoClass.create();
+ expect(pi.total()).toEqual(30);
+ expect(pi.count()).toEqual(25);
+ expect(pi.page()).toEqual(3);
+
+ // Recreate initial state
+ document.body.removeChild(p);
+ });
+ });
+});
diff --git a/dev/js/spec/pluginSpec.js b/dev/js/spec/pluginSpec.js
index 966d123..edffa59 100644
--- a/dev/js/spec/pluginSpec.js
+++ b/dev/js/spec/pluginSpec.js
@@ -623,7 +623,7 @@
KorAP.Pipe = temp;
});
- it('should reply to query information requests', function () {
+ it('should reply to query information requests (queryform)', function () {
var manager = pluginServerClass.create();
var id = manager.addService({"name":'Service', "src":'about:blank'});
expect(id).toMatch(/^id-/);
@@ -660,9 +660,41 @@
expect(data.value["q"]).toEqual("[orth=Baum]");
expect(data.value["ql"]).toEqual("poliqarp");
expect(data.value["cq"]).toEqual("title = /[^b]ee.+?/");
+
// Recreate initial state
KorAP.vc = temp;
document.body.removeChild(f);
});
+
+ it('should reply to query information requests (pagination)', function () {
+ var manager = pluginServerClass.create();
+ var id = manager.addService({"name":'Service', "src":'about:blank'});
+ expect(id).toMatch(/^id-/);
+
+ // 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);
+
+ let data = {
+ "originID" : id,
+ "action" : "get",
+ "key" : "Pagination"
+ };
+ manager._receiveMsg({
+ "data" : data
+ });
+ manager.destroy();
+ expect(data.value["count"]).toEqual(25);
+ expect(data.value["page"]).toEqual(3);
+ expect(data.value["total"]).toEqual(30);
+
+ // Recreate initial state
+ document.body.removeChild(p);
+ });
});
});