check running pazpar2
[mkws-moved-to-github.git] / test / spec / mkws-pazpar2.js
1 /* Copyright (c) 2013 IndexData ApS. http://indexdata.com
2  *
3  * perform papzpar2 / pz2.js search & retrieve request in the browser
4  *
5  */
6
7 function my_click(id, time) {
8     setTimeout(function () {
9         debug("trigger click on id: " + id);
10         $(id).trigger("click");
11     }, time * 1000);
12 }
13
14 function found(time) {
15     setTimeout(function () {
16         var found = $("#mkwsPager").html().match(/found: ([0-9]+)/);
17         debug("mkws pager found records: " + (found != null ? found[0] : "unknown"));
18     }, time * 1000);
19 }
20
21 describe("Check pazpar2 search", function () {
22     it("pazpar2 was successfully initialize", function () {
23         expect(mkws_config.error).toBe(undefined);
24     });
25
26     it("validate HTML id's", function () {
27         expect($("input#mkwsQuery").length == 1).toBe(true);
28         expect($("input#mkwsButton").length == 1).toBe(true);
29
30         expect($("#mkwsNext").length == 1).toBe(false);
31         expect($("#mkwsPrev").length == 1).toBe(false);
32     });
33
34     it("run search query", function () {
35         $("input#mkwsQuery").val("freebsd");
36         expect($("input#mkwsQuery").val()).toMatch(/^freebsd$/);
37
38         setTimeout(function () {
39             $("input#mkwsButton").trigger("click");
40         }, 3 * 1000);
41     });
42
43
44     it("check running search", function () {
45         my_click("#mkwsNext", 10);
46         my_click("#mkwsNext", 13);
47         my_click("#mkwsPrev", 15);
48
49         if ($("#mkwsPager").length) {
50             found(0);
51             found(5);
52             found(10);
53             found(15);
54             found(25);
55
56         } else {
57             debug("no mkws page found");
58         }
59     });
60
61 });