check running pazpar2
authorWolfram Schneider <wosch@indexdata.dk>
Thu, 22 Aug 2013 14:48:45 +0000 (16:48 +0200)
committerWolfram Schneider <wosch@indexdata.dk>
Thu, 22 Aug 2013 14:48:45 +0000 (16:48 +0200)
test/spec/mkws-pazpar2.js [new file with mode: 0644]

diff --git a/test/spec/mkws-pazpar2.js b/test/spec/mkws-pazpar2.js
new file mode 100644 (file)
index 0000000..491db0f
--- /dev/null
@@ -0,0 +1,61 @@
+/* Copyright (c) 2013 IndexData ApS. http://indexdata.com
+ *
+ * perform papzpar2 / pz2.js search & retrieve request in the browser
+ *
+ */
+
+function my_click(id, time) {
+    setTimeout(function () {
+        debug("trigger click on id: " + id);
+        $(id).trigger("click");
+    }, time * 1000);
+}
+
+function found(time) {
+    setTimeout(function () {
+        var found = $("#mkwsPager").html().match(/found: ([0-9]+)/);
+        debug("mkws pager found records: " + (found != null ? found[0] : "unknown"));
+    }, time * 1000);
+}
+
+describe("Check pazpar2 search", function () {
+    it("pazpar2 was successfully initialize", function () {
+        expect(mkws_config.error).toBe(undefined);
+    });
+
+    it("validate HTML id's", function () {
+        expect($("input#mkwsQuery").length == 1).toBe(true);
+        expect($("input#mkwsButton").length == 1).toBe(true);
+
+        expect($("#mkwsNext").length == 1).toBe(false);
+        expect($("#mkwsPrev").length == 1).toBe(false);
+    });
+
+    it("run search query", function () {
+        $("input#mkwsQuery").val("freebsd");
+        expect($("input#mkwsQuery").val()).toMatch(/^freebsd$/);
+
+        setTimeout(function () {
+            $("input#mkwsButton").trigger("click");
+        }, 3 * 1000);
+    });
+
+
+    it("check running search", function () {
+        my_click("#mkwsNext", 10);
+        my_click("#mkwsNext", 13);
+        my_click("#mkwsPrev", 15);
+
+        if ($("#mkwsPager").length) {
+            found(0);
+            found(5);
+            found(10);
+            found(15);
+            found(25);
+
+        } else {
+            debug("no mkws page found");
+        }
+    });
+
+});