run .unbind() earlier
[mkws-moved-to-github.git] / test / spec / mkws-pazpar2.js
index b353443..4e92869 100644 (file)
@@ -585,19 +585,26 @@ describe("Check removable facets links", function () {
         }, "Records DOM change mkwsRecords, removable", 2 * jasmine_config.second);
 
         runs(function () {
+            debug("unbind removable");
+            $("div.mkwsRecords").unbind("DOMNodeInserted DOMNodeRemoved propertychange");
+            waitcount = 0;
+
+            $("div.mkwsRecords").bind("DOMNodeInserted DOMNodeRemoved propertychange", function () {
+                waitcount++;
+                debug("DOM change mkwsRecords for removeable2: " + waitcount);
+            });
+
             var click = $("a.mkwsRemovable").eq(0).trigger("click");
             debug("Removed second facets link: " + click.length);
             expect(click.length).toBe(1);
         });
 
         waitsFor(function () {
-            // debug("wait for: " + waitcount);
-            return waitcount >= 4 && $("a.mkwsRemovable").length == 0 ? true : false;
+            return waitcount >= 2 && $("a.mkwsRemovable").length == 0 ? true : false;
         }, "DOM change mkwsRecords, removable2", 2 * jasmine_config.second);
 
-
         runs(function () {
-            debug("unbind removable");
+            debug("unbind removable2");
             $("div.mkwsRecords").unbind("DOMNodeInserted DOMNodeRemoved propertychange");
         });
     });
@@ -632,16 +639,13 @@ describe("Check per page options", function () {
         });
 
         waitsFor(function () {
-            //debug("wait for: " + waitcount);
             return waitcount >= (per_page_number * 2) ? true : false;
         }, "DOM change mkwsRecords, by per page", 3 * jasmine_config.second);
 
         runs(function () {
             $("div.mkwsRecords").unbind("DOMNodeInserted DOMNodeRemoved propertychange");
             debug("unbind per page");
-        });
 
-        runs(function () {
             var records = $("div.mkwsRecords > div.mkwsSummary");
             debug("Got now " + records.length + " records");
             expect(records.length).toBe(per_page_number);
@@ -696,10 +700,8 @@ describe("Check SortBy options", function () {
 
         runs(function () {
             $("div.mkwsRecords").unbind("DOMNodeInserted DOMNodeRemoved propertychange");
-            debug("unbind per page");
-        });
+            debug("unbind by sort");
 
-        runs(function () {
             var records = $("div.mkwsRecords > div.mkwsSummary a");
             debug("Got now " + records.length + " records");
             expect(records.length).toBe(per_page_number);
@@ -726,5 +728,6 @@ describe("Check SortBy options", function () {
 describe("All tests are done", function () {
     it(">>> hooray <<<", function () {
         mkws.jasmine_done = true;
+        debug(">>> hooray <<<");
     });
 });