- function found(time, none) {
- 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);
+ 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", 4 * 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", 4 * jasmine_config.second);
+
+ runs(function () {
+ expect($("div.mkwsFacetAuthors div.term").length).toBeGreaterThan(1);
+ });
+ });
+
+ it("limit search to first author", function () {
+ if (mkws_config.disable_facet_authors_search) {
+ debug("Facets: ignore limit search for authors");
+ return;
+ }
+
+ var hits_all_targets = get_hit_counter();
+ var author_number = 2; // 2=first author
+ // do not click on author with numbers, e.g.: "Bower, James M. Beeman, David, 1938-"
+ // do not click on author names without a comma, e.g.: "Joe Barbara"
+ var terms = $("div.mkwsFacetAuthors div.term a");
+ for (var i = 0; i < terms.length; i++) {
+ var term = $(terms[i]).text();
+ if (term.match(/[0-9].+[0-9]/i) || !term.match(/,/)) {
+ debug("ignore author facet: " + term);
+ author_number++;
+ } else {
+ break;
+ }