+ 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;
+ }
+ }
+
+ var click = $("div.mkwsFacetAuthors div.term:nth-child(" + author_number + ") a").trigger("click");
+ debug("limit author click is success: " + click.length);
+ expect(click.length).toBe(1);
+
+ waitsFor(function () {
+ return get_hit_counter() < hits_all_targets ? true : false;
+ }, "Limited author search for less than " + hits_all_targets + " hits", 6 * jasmine_config.second);
+
+ runs(function () {
+ var hits_single_target = get_hit_counter();
+ debug("get less hits for authors: " + hits_all_targets + " > " + hits_single_target);
+ expect(hits_all_targets).toBeGreaterThan(hits_single_target);
+ });
+ });
+
+ it("limit search to first source", function () {
+ var hits_all_targets = get_hit_counter();
+ var source_number = 2; // 2=first source
+ // do not click on wikipedia link - no author or subject facets possible
+ var terms = $("div#mkwsFacetSources div.term a");
+ for (var i = 0; i < terms.length; i++) {
+ var term = $(terms[i]).text();
+ if (term.match(/wikipedia/i)) {
+ debug("ignore source facet: " + term);
+ source_number++;
+ } else {
+ break;
+ }