X-Git-Url: http://git.indexdata.com/?p=mkws-moved-to-github.git;a=blobdiff_plain;f=test%2Fspec%2Fmkws-pazpar2.js;h=10f33363de37be3906c99f506401dbd358a16d28;hp=22a9456789efbe4135d18fcf8788fc10724e4601;hb=8111bf5133e4335ae1b14a79470d44b4c7003ce0;hpb=83482e7795dad8b6df4c5afe7d17700025185ff6 diff --git a/test/spec/mkws-pazpar2.js b/test/spec/mkws-pazpar2.js index 22a9456..10f3336 100644 --- a/test/spec/mkws-pazpar2.js +++ b/test/spec/mkws-pazpar2.js @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2014 IndexData ApS. http://indexdata.com +/* Copyright (c) 2013-2014 Index Data ApS. http://indexdata.com * * perform papzpar2 / pz2.js search & retrieve request in the browser * @@ -56,28 +56,30 @@ function init_jasmine_config() { } mkws.jasmine_done = false; -} - -var get_hit_counter = function () { - // not yet here - if ($(".mkwsPager").length == 0) return -1; - - var found = $(".mkwsPager").text(); - var re = /\([A-Za-z]+:\s+([0-9]+)\)/; - re.exec(found); - var hits = -1; +}; - if (RegExp.$1) { - hits = parseInt(RegExp.$1); - if (hits <= 0) { - debug("Oooops in get_hit_counter: " + RegExp.$1 + " '" + found + "'"); - } +function get_hit_counter() { + var $ = mkws.$; + // not yet here + if ($(".mkwsPager").length == 0) return -1; + + var found = $(".mkwsPager").text(); + var re = /\([A-Za-z]+:\s+([0-9]+)\)/; + re.exec(found); + var hits = -1; + + if (RegExp.$1) { + hits = parseInt(RegExp.$1); + if (hits <= 0) { + debug("Oooops in get_hit_counter: " + RegExp.$1 + " '" + found + "'"); } - - //debug("Hits: " + hits); - return hits; } + //debug("Hits: " + hits); + return hits; +}; + +/******************************************************************************/ describe("Init jasmine config", function () { it("jasmine was successfully initialized", function () { init_jasmine_config(); @@ -91,6 +93,8 @@ describe("Init jasmine config", function () { //disabled xdescribe("Check MOTD before search", function () { + var $ = mkws.$; + // Check that the MOTD has been moved into its container, and // is visible before the search. // the mkwsMOTD div was originally inside a testMOTD div, which should @@ -703,7 +707,7 @@ describe("Check SortBy options", function () { $("div.mkwsRecords").unbind("DOMNodeInserted DOMNodeRemoved propertychange"); debug("unbind by sort"); - var records = $("div.mkwsRecords > div.mkwsSummary a"); + var records = $("div.mkwsRecords > div.mkwsSummary > a"); debug("Sort by got now " + records.length + " records"); expect(records.length).toBe(per_page_number); }); @@ -724,6 +728,17 @@ describe("Check SortBy options", function () { }); }); +describe("Check async widget discovery", function () { + var $ = mkws.$; + it("initialises a new widget", function() { + $("div.mkwsSearch").after('
'); + mkws.init("Another search box"); + // mkws.init("Another search box", "#asyncSearch"); + waitsFor(function () { + return $("#asyncSearch input").length >= 1 ? true : false; + }, "Call init() to build an .mkwsSearch", 750); + }); +}); /* done */ describe("All tests are done", function () {