[devtools] qunit: stop using deprecated assert functions
authorRémi Cardona <remi.cardona@logilab.fr>
Wed, 20 May 2015 16:33:01 +0200
changeset 10426 ce213d6858f1
parent 10425 4be5dd6ac4e2
child 10427 7677c0401864
[devtools] qunit: stop using deprecated assert functions equals -> equal same -> deepEqual Related to #5533333.
devtools/test/data/js_examples/test_simple_failure.js
devtools/test/data/js_examples/test_simple_success.js
devtools/test/data/js_examples/test_with_dep.js
devtools/test/data/js_examples/test_with_ordered_deps.js
web/test/jstests/test_ajax.js
web/test/jstests/test_htmlhelpers.js
web/test/jstests/test_utils.js
--- a/devtools/test/data/js_examples/test_simple_failure.js	Wed May 13 18:39:29 2015 +0200
+++ b/devtools/test/data/js_examples/test_simple_failure.js	Wed May 20 16:33:01 2015 +0200
@@ -3,16 +3,16 @@
   module("air");
 
   test("test 1", function() {
-      equals(2, 4);
+      equal(2, 4);
   });
 
   test("test 2", function() {
-      equals('', '45');
-      equals('1024', '32');
+      equal('', '45');
+      equal('1024', '32');
   });
 
   module("able");
   test("test 3", function() {
-      same(1, 1);
+      deepEqual(1, 1);
   });
 });
--- a/devtools/test/data/js_examples/test_simple_success.js	Wed May 13 18:39:29 2015 +0200
+++ b/devtools/test/data/js_examples/test_simple_success.js	Wed May 20 16:33:01 2015 +0200
@@ -3,15 +3,15 @@
   module("air");
 
   test("test 1", function() {
-      equals(2, 2);
+      equal(2, 2);
   });
 
   test("test 2", function() {
-      equals('45', '45');
+      equal('45', '45');
   });
 
   module("able");
   test("test 3", function() {
-      same(1, 1);
+      deepEqual(1, 1);
   });
 });
--- a/devtools/test/data/js_examples/test_with_dep.js	Wed May 13 18:39:29 2015 +0200
+++ b/devtools/test/data/js_examples/test_with_dep.js	Wed May 20 16:33:01 2015 +0200
@@ -3,7 +3,7 @@
   module("air");
 
   test("test 1", function() {
-      equals(a, 4);
+      equal(a, 4);
   });
 
 });
--- a/devtools/test/data/js_examples/test_with_ordered_deps.js	Wed May 13 18:39:29 2015 +0200
+++ b/devtools/test/data/js_examples/test_with_ordered_deps.js	Wed May 20 16:33:01 2015 +0200
@@ -3,7 +3,7 @@
   module("air");
 
   test("test 1", function() {
-      equals(b, 6);
+      equal(b, 6);
   });
 
 });
--- a/web/test/jstests/test_ajax.js	Wed May 13 18:39:29 2015 +0200
+++ b/web/test/jstests/test_ajax.js	Wed May 20 16:33:01 2015 +0200
@@ -24,13 +24,13 @@
 
     test('test simple h1 inclusion (ajax_url0.html)', function() {
         expect(3);
-        equals(jQuery('#main').children().length, 0);
+        equal(jQuery('#main').children().length, 0);
         stop();
         jQuery('#main').loadxhtml(BASE_URL + 'cwsoftwareroot/web/test/jstests/ajax_url0.html')
         .addCallback(function() {
                 try {
-                    equals(jQuery('#main').children().length, 1);
-                    equals(jQuery('#main h1').html(), 'Hello');
+                    equal(jQuery('#main').children().length, 1);
+                    equal(jQuery('#main h1').html(), 'Hello');
                 } finally {
                     start();
                 };
@@ -41,7 +41,7 @@
     test('test simple html head inclusion (ajax_url1.html)', function() {
         expect(6);
         var scriptsIncluded = jsSources();
-        equals(jQuery.inArray('http://foo.js', scriptsIncluded), - 1);
+        equal(jQuery.inArray('http://foo.js', scriptsIncluded), - 1);
         stop();
         jQuery('#main').loadxhtml(BASE_URL + 'cwsoftwareroot/web/test/jstests/ajax_url1.html')
         .addCallback(function() {
@@ -49,12 +49,12 @@
                     var origLength = scriptsIncluded.length;
                     scriptsIncluded = jsSources();
                     // check that foo.js has been prepended to <head>
-                    equals(scriptsIncluded.length, origLength + 1);
-                    equals(scriptsIncluded.indexOf('http://foo.js'), 0);
+                    equal(scriptsIncluded.length, origLength + 1);
+                    equal(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);
-                    equals(jQuery('#main h1').html(), 'Hello');
+                    equal(jQuery('#main').children().length, 1);
+                    equal(jQuery('div.ajaxHtmlHead').length, 0);
+                    equal(jQuery('#main h1').html(), 'Hello');
                 } finally {
                     start();
                 };
@@ -64,13 +64,13 @@
 
     test('test addCallback', function() {
         expect(3);
-        equals(jQuery('#main').children().length, 0);
+        equal(jQuery('#main').children().length, 0);
         stop();
         var d = jQuery('#main').loadxhtml(BASE_URL + 'cwsoftwareroot/web/test/jstests/ajax_url0.html');
         d.addCallback(function() {
             try {
-                equals(jQuery('#main').children().length, 1);
-                equals(jQuery('#main h1').html(), 'Hello');
+                equal(jQuery('#main').children().length, 1);
+                equal(jQuery('#main h1').html(), 'Hello');
             } finally {
                 start();
             };
@@ -103,13 +103,13 @@
 
     test('test addCallback with parameters', function() {
         expect(3);
-        equals(jQuery('#main').children().length, 0);
+        equal(jQuery('#main').children().length, 0);
         stop();
         var d = jQuery('#main').loadxhtml(BASE_URL + 'cwsoftwareroot/web/test/jstests/ajax_url0.html');
         d.addCallback(function(data, req, arg1, arg2) {
             try {
-                equals(arg1, 'Hello');
-                equals(arg2, 'world');
+                equal(arg1, 'Hello');
+                equal(arg2, 'world');
             } finally {
                 start();
             };
@@ -124,8 +124,8 @@
             // add an assertion to ensure the callback is executed
             try {
                 ok(true, "callback is executed");
-                equals(arg1, 'Hello');
-                equals(arg2, 'world');
+                equal(arg1, 'Hello');
+                equal(arg2, 'world');
             } finally {
                 start();
             };
@@ -176,17 +176,17 @@
         var d = jQuery('#main').loadxhtml(BASE_URL + 'cwsoftwareroot/web/test/jstests/ajax_url0.html');
         d.addCallback(function() {
                 try {
-                    equals(++counter, 1); // should be executed first
+                    equal(++counter, 1); // should be executed first
                 } finally {
                     start();
                 };
             }
         );
         d.addCallback(function() {
-            equals(++counter, 2);
+            equal(++counter, 2);
         });
         d.addCallback(function() {
-            equals(++counter, 3);
+            equal(++counter, 3);
         });
     });
 
@@ -194,8 +194,8 @@
         expect(10);
         var scriptsIncluded = jsSources();
         // NOTE:
-        equals(jQuery.inArray('http://foo.js', scriptsIncluded), -1);
-        equals(jQuery('head link').length, 1);
+        equal(jQuery.inArray('http://foo.js', scriptsIncluded), -1);
+        equal(jQuery('head link').length, 1);
         /* use endswith because in pytest context we have an absolute path */
         ok(jQuery('head link').attr('href').endswith('/qunit.css'), 'qunit.css is loaded');
         stop();
@@ -205,14 +205,14 @@
                 scriptsIncluded = jsSources();
                 try {
                     // check that foo.js has been inserted in <head>
-                    equals(scriptsIncluded.length, origLength + 1);
-                    equals(scriptsIncluded.indexOf('http://foo.js'), 0);
+                    equal(scriptsIncluded.length, origLength + 1);
+                    equal(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);
-                    equals(jQuery('#main h1').html(), 'Hello');
+                    equal(jQuery('#main').children().length, 1);
+                    equal(jQuery('div.ajaxHtmlHead').length, 0);
+                    equal(jQuery('#main h1').html(), 'Hello');
                     // qunit.css is not added twice
-                    equals(jQuery('head link').length, 1);
+                    equal(jQuery('head link').length, 1);
                     /* use endswith because in pytest context we have an absolute path */
                     ok(jQuery('head link').attr('href').endswith('/qunit.css'), 'qunit.css is loaded');
                 } finally {
@@ -225,7 +225,7 @@
     test('test synchronous request loadRemote', function() {
         var res = loadRemote(BASE_URL + 'cwsoftwareroot/web/test/jstests/ajaxresult.json', {},
         'GET', true);
-        same(res, ['foo', 'bar']);
+        deepEqual(res, ['foo', 'bar']);
     });
 
     test('test event on CubicWeb', function() {
@@ -239,7 +239,7 @@
         jQuery('#main').loadxhtml(BASE_URL + 'cwsoftwareroot/web/test/jstests/ajax_url0.html')
         .addCallback(function() {
                 try {
-                    equals(events, 'CubicWeb');
+                    equal(events, 'CubicWeb');
                 } finally {
                     start();
                 };
@@ -260,11 +260,11 @@
         jQuery('#main').loadxhtml(BASE_URL + 'cwsoftwareroot/web/test/jstests/ajax_url0.html')
         .addCallback(function() {
                 try {
-                    equals(nodes.length, 2);
+                    equal(nodes.length, 2);
                     // check that server-response event on CubicWeb is triggered
                     // only once and event server-response on node is triggered
-                    equals(nodes[0], 'CubicWeb');
-                    equals(nodes[1], 'node');
+                    equal(nodes[0], 'CubicWeb');
+                    equal(nodes[1], 'node');
                 } finally {
                     start();
                 };
--- a/web/test/jstests/test_htmlhelpers.js	Wed May 13 18:39:29 2015 +0200
+++ b/web/test/jstests/test_htmlhelpers.js	Wed May 20 16:33:01 2015 +0200
@@ -13,7 +13,7 @@
     			     '<option value="baz">baz</option>' +
     			     '<option selected="selecetd"value="spam">spam</option>');
         var selected = firstSelected(document.getElementById("theselect"));
-        equals(selected.value, 'bar');
+        equal(selected.value, 'bar');
     });
 
     test("test first selected 2", function() {
@@ -22,7 +22,7 @@
     			     '<option value="baz">baz</option>' +
     			     '<option value="spam">spam</option>');
         var selected = firstSelected(document.getElementById("theselect"));
-        equals(selected, null);
+        equal(selected, null);
     });
 
     module("visibilty");
--- a/web/test/jstests/test_utils.js	Wed May 13 18:39:29 2015 +0200
+++ b/web/test/jstests/test_utils.js	Wed May 20 16:33:01 2015 +0200
@@ -3,55 +3,55 @@
   module("datetime");
 
   test("test full datetime", function() {
-      equals(cw.utils.toISOTimestamp(new Date(1986, 3, 18, 10, 30, 0, 0)),
+      equal(cw.utils.toISOTimestamp(new Date(1986, 3, 18, 10, 30, 0, 0)),
 	     '1986-04-18 10:30:00');
   });
 
   test("test only date", function() {
-      equals(cw.utils.toISOTimestamp(new Date(1986, 3, 18)), '1986-04-18 00:00:00');
+      equal(cw.utils.toISOTimestamp(new Date(1986, 3, 18)), '1986-04-18 00:00:00');
   });
 
   test("test null", function() {
-      equals(cw.utils.toISOTimestamp(null), null);
+      equal(cw.utils.toISOTimestamp(null), null);
   });
 
   module("parsing");
   test("test basic number parsing", function() {
       var d = strptime('2008/08/08', '%Y/%m/%d');
-      same(datetuple(d), [2008, 8, 8, 0, 0]);
+      deepEqual(datetuple(d), [2008, 8, 8, 0, 0]);
       d = strptime('2008/8/8', '%Y/%m/%d');
-      same(datetuple(d), [2008, 8, 8, 0, 0]);
+      deepEqual(datetuple(d), [2008, 8, 8, 0, 0]);
       d = strptime('8/8/8', '%Y/%m/%d');
-      same(datetuple(d), [8, 8, 8, 0, 0]);
+      deepEqual(datetuple(d), [8, 8, 8, 0, 0]);
       d = strptime('0/8/8', '%Y/%m/%d');
-      same(datetuple(d), [0, 8, 8, 0, 0]);
+      deepEqual(datetuple(d), [0, 8, 8, 0, 0]);
       d = strptime('-10/8/8', '%Y/%m/%d');
-      same(datetuple(d), [-10, 8, 8, 0, 0]);
+      deepEqual(datetuple(d), [-10, 8, 8, 0, 0]);
       d = strptime('-35000', '%Y');
-      same(datetuple(d), [-35000, 1, 1, 0, 0]);
+      deepEqual(datetuple(d), [-35000, 1, 1, 0, 0]);
   });
 
   test("test custom format parsing", function() {
       var d = strptime('2008-08-08', '%Y-%m-%d');
-      same(datetuple(d), [2008, 8, 8, 0, 0]);
+      deepEqual(datetuple(d), [2008, 8, 8, 0, 0]);
       d = strptime('2008 - !  08: 08', '%Y - !  %m: %d');
-      same(datetuple(d), [2008, 8, 8, 0, 0]);
+      deepEqual(datetuple(d), [2008, 8, 8, 0, 0]);
       d = strptime('2008-08-08 12:14', '%Y-%m-%d %H:%M');
-      same(datetuple(d), [2008, 8, 8, 12, 14]);
+      deepEqual(datetuple(d), [2008, 8, 8, 12, 14]);
       d = strptime('2008-08-08 1:14', '%Y-%m-%d %H:%M');
-      same(datetuple(d), [2008, 8, 8, 1, 14]);
+      deepEqual(datetuple(d), [2008, 8, 8, 1, 14]);
       d = strptime('2008-08-08 01:14', '%Y-%m-%d %H:%M');
-      same(datetuple(d), [2008, 8, 8, 1, 14]);
+      deepEqual(datetuple(d), [2008, 8, 8, 1, 14]);
   });
 
   module("sliceList");
   test("test slicelist", function() {
       var list = ['a', 'b', 'c', 'd', 'e', 'f'];
-      same(cw.utils.sliceList(list, 2),  ['c', 'd', 'e', 'f']);
-      same(cw.utils.sliceList(list, 2, -2), ['c', 'd']);
-      same(cw.utils.sliceList(list, -3), ['d', 'e', 'f']);
-      same(cw.utils.sliceList(list, 0, -2), ['a', 'b', 'c', 'd']);
-      same(cw.utils.sliceList(list),  list);
+      deepEqual(cw.utils.sliceList(list, 2),  ['c', 'd', 'e', 'f']);
+      deepEqual(cw.utils.sliceList(list, 2, -2), ['c', 'd']);
+      deepEqual(cw.utils.sliceList(list, -3), ['d', 'e', 'f']);
+      deepEqual(cw.utils.sliceList(list, 0, -2), ['a', 'b', 'c', 'd']);
+      deepEqual(cw.utils.sliceList(list),  list);
   });
 
   module("formContents", {
@@ -83,7 +83,7 @@
 			     'value="one" />');
       $('#test-form').append('<input name="unchecked-choice" type="radio" ' +
 			     'value="two"/>');
-      same(cw.utils.formContents($('#test-form')[0]), [
+      deepEqual(cw.utils.formContents($('#test-form')[0]), [
 	['input-text', 'mytextarea', 'choice', 'check', 'theselect'],
 	['toto', 'Hello World!', 'no', 'no', 'foo']
       ]);