- var max_time = 13;
- var j_time = 0;
- var j_hits = 0;
-
- function found(time, none) {
- describe("found hits", function () {
- setTimeout(function () {
- j_time = time;
-
- var found = $("#mkwsPager").text();
- var re = /found: ([0-9]+)/;
- re.exec(found);
- var hits = -1;
-
- if (RegExp.$1) {
- hits = RegExp.$1;
- expect(hits).toBeGreaterThan(0);
- }
-
- // debug("found: " + found);
- if (none) {
- expect(hits < 0).toBeTruthy();
- } else {
- j_hits = hits;
- }
-
- debug("mkws pager found records: '" + hits + "'");
- debug("time state: " + j_time);
-
- expect(time >= 0).toBeTruthy();
- }, time * 1000);
- });
+ var max_time = jasmine_config.max_time; // in seconds
+ var expected_hits = jasmine_config.expected_hits; // at least expected hit counter
+ var hits = 0;
+
+ waitsFor(function () {
+ hits = get_hit_counter();
+
+ return hits > expected_hits;
+ }, "Expect " + expected_hits + " hits", max_time * jasmine_config.second);
+
+
+ runs(function () {
+ debug("mkws pager found records: '" + hits + "'");
+ expect($("#mkwsPager").length).toBe(1);
+ expect(hits).toBeGreaterThan(expected_hits);
+ });
+ });
+});
+
+describe("Check Termlist", function () {
+ it("found Termlist", function () {
+ var termlist = $("div#mkwsTermlists");
+ debug("Termlist success: " + termlist.length);
+ expect(termlist.length).toBe(1);
+
+ waitsFor(function () {
+ return $("div#mkwsFacetSources").length == 1 ? true : false;
+ }, "check for facet sources", 2 * jasmine_config.second);
+
+
+ // everything displayed?
+ runs(function () {
+ var sources = $("div#mkwsFacetSources");
+ debug("Termlist sources success: " + sources.length);
+ expect(sources.length).toBe(1);
+
+ var subjects = $("div#mkwsFacetSubjects");
+ expect(subjects.length).toBe(1);
+
+ var authors = $("div#mkwsFacetAuthors");
+ expect(authors.length).toBe(1);
+ });
+
+ waitsFor(function () {
+ return $("div#mkwsFacetAuthors div.term").length >= 2 ? true : false;
+ }, "At least one author link displayed", 2 * jasmine_config.second);
+
+ runs(function () {
+ expect($("div#mkwsFacetAuthors div.term").length).toBeGreaterThan(1);
+ });
+ });
+
+ it("limit search to first author", function () {
+ var hits_all_targets = get_hit_counter();
+ var author_number = 2; // 2=first author
+ var author_name = $("div#mkwsFacetAuthors div.term:nth-child(" + author_number + ") a").text();
+ // do not click on author with numbers, e.g.: Bower, James M. Beeman, David, 1938-
+ if (author_name.match(/[0-9].+[0-9]/)) {
+ author_number++;