[javascript] fix test_ajax.js implementation stable
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Mon, 13 Sep 2010 09:56:10 +0200
branchstable
changeset 6214 e03808843325
parent 6213 efde9f08f2ae
child 6215 759cf097f5aa
[javascript] fix test_ajax.js implementation In cubicweb.ajax.js, we maintain two lists (cw.loaded_src and cw.loaded_href) to keep track of already included CSS and JS. (see discussion about jQuery and $('foo').appendTo($head) in _loadAjaxHtmlHead.) Since all tests are executed in the "same page", those two variables need to be reinitialized before each test.
web/test/jstests/test_ajax.js
--- a/web/test/jstests/test_ajax.js	Mon Sep 13 10:00:05 2010 +0200
+++ b/web/test/jstests/test_ajax.js	Mon Sep 13 09:56:10 2010 +0200
@@ -3,7 +3,12 @@
     module("ajax", {
         setup: function() {
           this.scriptsLength = $('head script[src]').length-1;
-	  this.cssLength = $('head link[rel=stylesheet]').length-1;
+          this.cssLength = $('head link[rel=stylesheet]').length-1;
+          // re-initialize cw loaded cache so that each tests run in a
+          // clean environment, have a lookt at _loadAjaxHtmlHead implementation
+          // in cubicweb.ajax.js for more information.
+          cw.loaded_src = [];
+          cw.loaded_href = [];
         },
         teardown: function() {
           $('head script[src]:gt(' + this.scriptsLength + ')').remove();