1 /* Copyright (c) 2013 IndexData ApS. http://indexdata.com
3 * perform papzpar2 / pz2.js search & retrieve request in the browser
12 function my_click(id, time) {
13 setTimeout(function () {
14 debug("trigger click on id: " + id);
15 $(id).trigger("click");
19 function found(time, none) {
20 setTimeout(function () {
21 jasmine_state.time = time;
23 var found = $("#mkwsPager").html().match(/found: ([0-9]+)/);
25 describe("pazpar2 hit count", function () {
27 it("no results yet", function () {
28 expect(found).toBe(null);
31 it("got results", function () {
32 expect(found[0]).toMatch(/^[0-9]+$/);
35 debug("mkws pager found records: " + (found != null ? found[0] : "unknown"));
36 debug("time state: " + jasmine_state.time);
42 describe("Check pazpar2 search", function () {
43 it("pazpar2 was successfully initialize", function () {
44 expect(mkws_config.error).toBe(undefined);
47 it("validate HTML id's", function () {
48 expect($("input#mkwsQuery").length == 1).toBe(true);
49 expect($("input#mkwsButton").length == 1).toBe(true);
51 expect($("#mkwsNext").length == 1).toBe(false);
52 expect($("#mkwsPrev").length == 1).toBe(false);
55 it("run search query", function () {
56 $("input#mkwsQuery").val("freebsd");
57 expect($("input#mkwsQuery").val()).toMatch(/^freebsd$/);
59 setTimeout(function () {
60 $("input#mkwsButton").trigger("click");
66 it("check running search", function () {
69 expect($("#mkwsPager").length == 1).toBe(true);
72 // click next/prev after N seconds
73 my_click("#mkwsNext", 10);
74 my_click("#mkwsNext", 13);
75 my_click("#mkwsPrev", 15);
77 // check hit counter after N seconds
86 waitsFor(function () {
87 return jasmine_state.time == max_time ? true : false;
88 }, "The Value should be 20 seconds", 30 * 1000); // (max_time + 1) * 1000);
91 expect($("#mkwsPager").length == 1).toBe(true);
96 expect(jasmine_state.time).toEqual(max_time);