[web/test] Fix remaining JS tests (closes #5533303)
authorRémi Cardona <remi.cardona@logilab.fr>
Wed, 13 May 2015 16:43:03 +0200
changeset 10419 5edd38e3205f
parent 10418 e1076102bd84
child 10420 da7699ccad68
[web/test] Fix remaining JS tests (closes #5533303)
web/test/jstests/test_ajax.js
--- a/web/test/jstests/test_ajax.js	Wed May 13 16:42:01 2015 +0200
+++ b/web/test/jstests/test_ajax.js	Wed May 13 16:43:03 2015 +0200
@@ -11,7 +11,7 @@
           cw.loaded_links = [];
         },
         teardown: function() {
-          $('head script[src]:gt(' + this.scriptsLength + ')').remove();
+          $('head script[src]:lt(' + ($('head script[src]').length - 1 - this.scriptsLength) + ')').remove();
           $('head link[rel=stylesheet]:gt(' + this.cssLength + ')').remove();
         }
       });
@@ -48,9 +48,9 @@
                 try {
                     var origLength = scriptsIncluded.length;
                     scriptsIncluded = jsSources();
-                    // check that foo.js has been *appended* to <head>
+                    // check that foo.js has been prepended to <head>
                     equals(scriptsIncluded.length, origLength + 1);
-                    equals(scriptsIncluded[origLength].indexOf('http://foo.js'), 0);
+                    equals(scriptsIncluded.indexOf('http://foo.js'), 0);
                     // check that <div class="ajaxHtmlHead"> has been removed
                     equals(jQuery('#main').children().length, 1);
                     equals(jQuery('div.ajaxHtmlHead').length, 0);
@@ -118,7 +118,7 @@
     });
 
     test('test callback after synchronous request with parameters', function() {
-        expect(2);
+        expect(3);
         var deferred = new Deferred();
         deferred.addCallback(function(data, req, arg1, arg2) {
             // add an assertion to ensure the callback is executed
@@ -206,7 +206,7 @@
                 try {
                     // check that foo.js has been inserted in <head>
                     equals(scriptsIncluded.length, origLength + 1);
-                    equals(scriptsIncluded[origLength].indexOf('http://foo.js'), 0);
+                    equals(scriptsIncluded.indexOf('http://foo.js'), 0);
                     // check that <div class="ajaxHtmlHead"> has been removed
                     equals(jQuery('#main').children().length, 1);
                     equals(jQuery('div.ajaxHtmlHead').length, 0);