From f35ba5e699c15a1987baa389dbd4fc99f7a7eb03 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Sun, 6 Nov 2011 15:27:42 -0500 Subject: Fix #10691. Remove all instances of equals() and same(), as these are deprecated in QUnit. --- test/data/testinit.js | 10 +- test/data/testrunner.js | 6 - test/unit/ajax.js | 200 +++++++-------- test/unit/attributes.js | 386 ++++++++++++++-------------- test/unit/callbacks.js | 4 +- test/unit/core.js | 466 ++++++++++++++++----------------- test/unit/css.js | 158 ++++++------ test/unit/data.js | 156 +++++------ test/unit/deferred.js | 6 +- test/unit/dimensions.js | 116 ++++----- test/unit/effects.js | 148 +++++------ test/unit/event.js | 640 +++++++++++++++++++++++----------------------- test/unit/manipulation.js | 414 +++++++++++++++--------------- test/unit/offset.js | 170 ++++++------ test/unit/queue.js | 44 ++-- test/unit/traversing.js | 366 +++++++++++++------------- 16 files changed, 1642 insertions(+), 1648 deletions(-) (limited to 'test') diff --git a/test/data/testinit.js b/test/data/testinit.js index ac97e181a..aeda2433b 100644 --- a/test/data/testinit.js +++ b/test/data/testinit.js @@ -41,7 +41,7 @@ function t(a,b,c) { s += (s && ",") + '"' + f[i].id + '"'; } - same(f, q.apply(q,c), a + " (" + b + ")"); + deepEqual(f, q.apply(q,c), a + " (" + b + ")"); } var fireNative; @@ -102,19 +102,19 @@ function url(value) { // Because QUnit doesn't have a mechanism for retrieving the number of expected assertions for a test, // if we unconditionally assert any of these, the test will fail with too many assertions :| if ( cacheLength !== oldCacheLength ) { - equals( cacheLength, oldCacheLength, "No unit tests leak memory in jQuery.cache" ); + equal( cacheLength, oldCacheLength, "No unit tests leak memory in jQuery.cache" ); oldCacheLength = cacheLength; } if ( fragmentsLength !== oldFragmentsLength ) { - equals( fragmentsLength, oldFragmentsLength, "No unit tests leak memory in jQuery.fragments" ); + equal( fragmentsLength, oldFragmentsLength, "No unit tests leak memory in jQuery.fragments" ); oldFragmentsLength = fragmentsLength; } if ( jQuery.timers.length !== oldTimersLength ) { - equals( jQuery.timers.length, oldTimersLength, "No timers are still running" ); + equal( jQuery.timers.length, oldTimersLength, "No timers are still running" ); oldTimersLength = jQuery.timers.length; } if ( jQuery.active !== oldActive ) { - equals( jQuery.active, 0, "No AJAX requests are still active" ); + equal( jQuery.active, 0, "No AJAX requests are still active" ); oldActive = jQuery.active; } } diff --git a/test/data/testrunner.js b/test/data/testrunner.js index abe85f087..bdfbcac9a 100644 --- a/test/data/testrunner.js +++ b/test/data/testrunner.js @@ -25,9 +25,3 @@ jQuery.noConflict(); // Allow the test to run with other libs or jQuery's. document.write(""); })(); - -// QUnit Aliases -(function() { - window.equals = window.equal; - window.same = window.deepEqual; -})(); diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 9e11087b0..67e0d2c8f 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -474,7 +474,7 @@ test(".ajax() - protocol-less urls", function() { jQuery.ajax({ url: "//somedomain.com", beforeSend: function( xhr, settings ) { - equals(settings.url, location.protocol + "//somedomain.com", "Make sure that the protocol is added."); + equal(settings.url, location.protocol + "//somedomain.com", "Make sure that the protocol is added."); return false; } }); @@ -486,7 +486,7 @@ test(".ajax() - hash", function() { jQuery.ajax({ url: "data/name.html#foo", beforeSend: function( xhr, settings ) { - equals(settings.url, "data/name.html", "Make sure that the URL is trimmed."); + equal(settings.url, "data/name.html", "Make sure that the URL is trimmed."); return false; } }); @@ -494,7 +494,7 @@ test(".ajax() - hash", function() { jQuery.ajax({ url: "data/name.html?abc#foo", beforeSend: function( xhr, settings ) { - equals(settings.url, "data/name.html?abc", "Make sure that the URL is trimmed."); + equal(settings.url, "data/name.html?abc", "Make sure that the URL is trimmed."); return false; } }); @@ -503,7 +503,7 @@ test(".ajax() - hash", function() { url: "data/name.html?abc#foo", data: { "test": 123 }, beforeSend: function( xhr, settings ) { - equals(settings.url, "data/name.html?abc&test=123", "Make sure that the URL is trimmed."); + equal(settings.url, "data/name.html?abc&test=123", "Make sure that the URL is trimmed."); return false; } }); @@ -619,10 +619,10 @@ test("jQuery.ajax() - abort", function() { complete: function(){ ok(true, "complete"); } }); - equals( xhr.readyState, 1, "XHR readyState indicates successful dispatch" ); + equal( xhr.readyState, 1, "XHR readyState indicates successful dispatch" ); xhr.abort(); - equals( xhr.readyState, 0, "XHR readyState indicates successful abortion" ); + equal( xhr.readyState, 0, "XHR readyState indicates successful abortion" ); }); test("Ajax events with context", function() { @@ -632,18 +632,18 @@ test("Ajax events with context", function() { var context = document.createElement("div"); function event(e){ - equals( this, context, e.type ); + equal( this, context, e.type ); } function callback(msg){ return function(){ - equals( this, context, "context is preserved on callback " + msg ); + equal( this, context, "context is preserved on callback " + msg ); }; } function nocallback(msg){ return function(){ - equals( typeof this.url, "string", "context is settings on callback " + msg ); + equal( typeof this.url, "string", "context is settings on callback " + msg ); }; } @@ -705,7 +705,7 @@ test("jQuery.ajax context modification", function() { } }); - equals( obj.test, "foo", "Make sure the original object is maintained." ); + equal( obj.test, "foo", "Make sure the original object is maintained." ); }); test("jQuery.ajax context modification through ajaxSetup", function() { @@ -787,9 +787,9 @@ test("jQuery.ajax - xml: non-namespace elements inside namespaced elements", fun url: url("data/with_fries.xml"), dataType: "xml", success: function(resp) { - equals( jQuery("properties", resp).length, 1, "properties in responseXML" ); - equals( jQuery("jsconf", resp).length, 1, "jsconf in responseXML" ); - equals( jQuery("thing", resp).length, 2, "things in responseXML" ); + equal( jQuery("properties", resp).length, 1, "properties in responseXML" ); + equal( jQuery("jsconf", resp).length, 1, "jsconf in responseXML" ); + equal( jQuery("thing", resp).length, 2, "things in responseXML" ); start(); } }); @@ -802,9 +802,9 @@ test("jQuery.ajax - xml: non-namespace elements inside namespaced elements (over url: url("data/with_fries_over_jsonp.php"), dataType: "jsonp xml", success: function(resp) { - equals( jQuery("properties", resp).length, 1, "properties in responseXML" ); - equals( jQuery("jsconf", resp).length, 1, "jsconf in responseXML" ); - equals( jQuery("thing", resp).length, 2, "things in responseXML" ); + equal( jQuery("properties", resp).length, 1, "properties in responseXML" ); + equal( jQuery("jsconf", resp).length, 1, "jsconf in responseXML" ); + equal( jQuery("thing", resp).length, 2, "things in responseXML" ); start(); }, error: function(_1,_2,error) { @@ -910,8 +910,8 @@ test("jQuery.ajax - dataType html", function() { stop(); var verifyEvaluation = function() { - equals( testFoo, "foo", "Check if script was evaluated for datatype html" ); - equals( foobar, "bar", "Check if script src was evaluated for datatype html" ); + equal( testFoo, "foo", "Check if script was evaluated for datatype html" ); + equal( foobar, "bar", "Check if script src was evaluated for datatype html" ); start(); }; @@ -936,28 +936,28 @@ test("serialize()", function() { "" ); - equals( jQuery("#form").serialize(), + equal( jQuery("#form").serialize(), "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3", "Check form serialization as query string"); - equals( jQuery("#form :input").serialize(), + equal( jQuery("#form :input").serialize(), "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3", "Check input serialization as query string"); - equals( jQuery("#testForm").serialize(), + equal( jQuery("#testForm").serialize(), "T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=", "Check form serialization as query string"); - equals( jQuery("#testForm :input").serialize(), + equal( jQuery("#testForm :input").serialize(), "T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=", "Check input serialization as query string"); - equals( jQuery("#form, #testForm").serialize(), + equal( jQuery("#form, #testForm").serialize(), "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3&T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=", "Multiple form serialization as query string"); /* Temporarily disabled. Opera 10 has problems with form serialization. - equals( jQuery("#form, #testForm :input").serialize(), + equal( jQuery("#form, #testForm :input").serialize(), "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=", "Mixed form/input serialization as query string"); */ @@ -967,68 +967,68 @@ test("serialize()", function() { test("jQuery.param()", function() { expect(21); - equals( !jQuery.ajaxSettings.traditional, true, "traditional flag, falsy by default" ); + equal( !jQuery.ajaxSettings.traditional, true, "traditional flag, falsy by default" ); var params = {foo:"bar", baz:42, quux:"All your base are belong to us"}; - equals( jQuery.param(params), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" ); + equal( jQuery.param(params), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" ); params = {someName: [1, 2, 3], regularThing: "blah" }; - equals( jQuery.param(params), "someName%5B%5D=1&someName%5B%5D=2&someName%5B%5D=3®ularThing=blah", "with array" ); + equal( jQuery.param(params), "someName%5B%5D=1&someName%5B%5D=2&someName%5B%5D=3®ularThing=blah", "with array" ); params = {foo: ["a", "b", "c"]}; - equals( jQuery.param(params), "foo%5B%5D=a&foo%5B%5D=b&foo%5B%5D=c", "with array of strings" ); + equal( jQuery.param(params), "foo%5B%5D=a&foo%5B%5D=b&foo%5B%5D=c", "with array of strings" ); params = {foo: ["baz", 42, "All your base are belong to us"] }; - equals( jQuery.param(params), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" ); + equal( jQuery.param(params), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" ); params = {foo: { bar: "baz", beep: 42, quux: "All your base are belong to us" } }; - equals( jQuery.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" ); + equal( jQuery.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" ); params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" }; - equals( decodeURIComponent( jQuery.param(params) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=undefined&i[]=10&i[]=11&j=true&k=false&l[]=undefined&l[]=0&m=cowboy+hat?", "huge structure" ); + equal( decodeURIComponent( jQuery.param(params) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=undefined&i[]=10&i[]=11&j=true&k=false&l[]=undefined&l[]=0&m=cowboy+hat?", "huge structure" ); params = { a: [ 0, [ 1, 2 ], [ 3, [ 4, 5 ], [ 6 ] ], { b: [ 7, [ 8, 9 ], [ { c: 10, d: 11 } ], [ [ 12 ] ], [ [ [ 13 ] ] ], { e: { f: { g: [ 14, [ 15 ] ] } } }, 16 ] }, 17 ] }; - equals( decodeURIComponent( jQuery.param(params) ), "a[]=0&a[1][]=1&a[1][]=2&a[2][]=3&a[2][1][]=4&a[2][1][]=5&a[2][2][]=6&a[3][b][]=7&a[3][b][1][]=8&a[3][b][1][]=9&a[3][b][2][0][c]=10&a[3][b][2][0][d]=11&a[3][b][3][0][]=12&a[3][b][4][0][0][]=13&a[3][b][5][e][f][g][]=14&a[3][b][5][e][f][g][1][]=15&a[3][b][]=16&a[]=17", "nested arrays" ); + equal( decodeURIComponent( jQuery.param(params) ), "a[]=0&a[1][]=1&a[1][]=2&a[2][]=3&a[2][1][]=4&a[2][1][]=5&a[2][2][]=6&a[3][b][]=7&a[3][b][1][]=8&a[3][b][1][]=9&a[3][b][2][0][c]=10&a[3][b][2][0][d]=11&a[3][b][3][0][]=12&a[3][b][4][0][0][]=13&a[3][b][5][e][f][g][]=14&a[3][b][5][e][f][g][1][]=15&a[3][b][]=16&a[]=17", "nested arrays" ); params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" }; - equals( jQuery.param(params,true), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=undefined&l=0&m=cowboy+hat%3F", "huge structure, forced traditional" ); + equal( jQuery.param(params,true), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=undefined&l=0&m=cowboy+hat%3F", "huge structure, forced traditional" ); - equals( decodeURIComponent( jQuery.param({ a: [1,2,3], "b[]": [4,5,6], "c[d]": [7,8,9], e: { f: [10], g: [11,12], h: 13 } }) ), "a[]=1&a[]=2&a[]=3&b[]=4&b[]=5&b[]=6&c[d][]=7&c[d][]=8&c[d][]=9&e[f][]=10&e[g][]=11&e[g][]=12&e[h]=13", "Make sure params are not double-encoded." ); + equal( decodeURIComponent( jQuery.param({ a: [1,2,3], "b[]": [4,5,6], "c[d]": [7,8,9], e: { f: [10], g: [11,12], h: 13 } }) ), "a[]=1&a[]=2&a[]=3&b[]=4&b[]=5&b[]=6&c[d][]=7&c[d][]=8&c[d][]=9&e[f][]=10&e[g][]=11&e[g][]=12&e[h]=13", "Make sure params are not double-encoded." ); // #7945 - equals( jQuery.param({"jquery": "1.4.2"}), "jquery=1.4.2", "Check that object with a jQuery property get serialized correctly" ); + equal( jQuery.param({"jquery": "1.4.2"}), "jquery=1.4.2", "Check that object with a jQuery property get serialized correctly" ); jQuery.ajaxSetup({ traditional: true }); var params = {foo:"bar", baz:42, quux:"All your base are belong to us"}; - equals( jQuery.param(params), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" ); + equal( jQuery.param(params), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" ); params = {someName: [1, 2, 3], regularThing: "blah" }; - equals( jQuery.param(params), "someName=1&someName=2&someName=3®ularThing=blah", "with array" ); + equal( jQuery.param(params), "someName=1&someName=2&someName=3®ularThing=blah", "with array" ); params = {foo: ["a", "b", "c"]}; - equals( jQuery.param(params), "foo=a&foo=b&foo=c", "with array of strings" ); + equal( jQuery.param(params), "foo=a&foo=b&foo=c", "with array of strings" ); params = {"foo[]":["baz", 42, "All your base are belong to us"]}; - equals( jQuery.param(params), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" ); + equal( jQuery.param(params), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" ); params = {"foo[bar]":"baz", "foo[beep]":42, "foo[quux]":"All your base are belong to us"}; - equals( jQuery.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" ); + equal( jQuery.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" ); params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" }; - equals( jQuery.param(params), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=undefined&l=0&m=cowboy+hat%3F", "huge structure" ); + equal( jQuery.param(params), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=undefined&l=0&m=cowboy+hat%3F", "huge structure" ); params = { a: [ 0, [ 1, 2 ], [ 3, [ 4, 5 ], [ 6 ] ], { b: [ 7, [ 8, 9 ], [ { c: 10, d: 11 } ], [ [ 12 ] ], [ [ [ 13 ] ] ], { e: { f: { g: [ 14, [ 15 ] ] } } }, 16 ] }, 17 ] }; - equals( jQuery.param(params), "a=0&a=1%2C2&a=3%2C4%2C5%2C6&a=%5Bobject+Object%5D&a=17", "nested arrays (not possible when jQuery.param.traditional == true)" ); + equal( jQuery.param(params), "a=0&a=1%2C2&a=3%2C4%2C5%2C6&a=%5Bobject+Object%5D&a=17", "nested arrays (not possible when jQuery.param.traditional == true)" ); params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" }; - equals( decodeURIComponent( jQuery.param(params,false) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=undefined&i[]=10&i[]=11&j=true&k=false&l[]=undefined&l[]=0&m=cowboy+hat?", "huge structure, forced not traditional" ); + equal( decodeURIComponent( jQuery.param(params,false) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=undefined&i[]=10&i[]=11&j=true&k=false&l[]=undefined&l[]=0&m=cowboy+hat?", "huge structure, forced not traditional" ); params = { param1: null }; - equals( jQuery.param(params,false), "param1=null", "Make sure that null params aren't traversed." ); + equal( jQuery.param(params,false), "param1=null", "Make sure that null params aren't traversed." ); params = {"test": {"length": 3, "foo": "bar"} }; - equals( jQuery.param( params, false ), "test%5Blength%5D=3&test%5Bfoo%5D=bar", "Sub-object with a length property" ); + equal( jQuery.param( params, false ), "test%5Blength%5D=3&test%5Bfoo%5D=bar", "Sub-object with a length property" ); }); test("synchronous request", function() { @@ -1059,8 +1059,8 @@ test("pass-through request object", function() { errorEx += ": " + xml.status; }); jQuery("#foo").one("ajaxStop", function () { - equals(successCount, 5, "Check all ajax calls successful"); - equals(errorCount, 0, "Check no ajax errors (status" + errorEx + ")"); + equal(successCount, 5, "Check all ajax calls successful"); + equal(errorCount, 0, "Check no ajax errors (status" + errorEx + ")"); jQuery("#foo").unbind("ajaxError"); start(); @@ -1090,7 +1090,7 @@ test("ajax cache", function () { } oldOne = ret[1]; } - equals(i, 1, "Test to make sure only one 'no-cache' parameter is there"); + equal(i, 1, "Test to make sure only one 'no-cache' parameter is there"); ok(oldOne != "tobereplaced555", "Test to be sure parameter (if it was there) was replaced"); if(++count == 6) start(); @@ -1143,7 +1143,7 @@ test("load('url selector')", function() { expect(1); stop(); // check if load can be called with only url jQuery("#first").load("data/test3.html div.user", function(){ - equals( jQuery(this).children("div").length, 2, "Verify that specific elements were injected" ); + equal( jQuery(this).children("div").length, 2, "Verify that specific elements were injected" ); start(); }); }); @@ -1153,7 +1153,7 @@ test("load(String, Function) with ajaxSetup on dataType json, see #2046", functi stop(); jQuery.ajaxSetup({ dataType: "json" }); jQuery("#first").ajaxComplete(function (e, xml, s) { - equals( s.dataType, "html", "Verify the load() dataType was html" ); + equal( s.dataType, "html", "Verify the load() dataType was html" ); jQuery("#first").unbind("ajaxComplete"); jQuery.ajaxSetup({ dataType: "" }); start(); @@ -1175,15 +1175,15 @@ test("load(String, Function) - check scripts", function() { stop(); var verifyEvaluation = function() { - equals( foobar, "bar", "Check if script src was evaluated after load" ); - equals( jQuery("#ap").html(), "bar", "Check if script evaluation has modified DOM"); + equal( foobar, "bar", "Check if script src was evaluated after load" ); + equal( jQuery("#ap").html(), "bar", "Check if script evaluation has modified DOM"); start(); }; jQuery("#first").load(url("data/test.html"), function() { ok( jQuery("#first").html().match(/^html text/), "Check content after loading html" ); - equals( jQuery("#foo").html(), "foo", "Check if script evaluation has modified DOM"); - equals( testFoo, "foo", "Check if script was evaluated after load" ); + equal( jQuery("#foo").html(), "foo", "Check if script evaluation has modified DOM"); + equal( testFoo, "foo", "Check if script was evaluated after load" ); setTimeout(verifyEvaluation, 600); }); }); @@ -1193,8 +1193,8 @@ test("load(String, Function) - check file with only a script tag", function() { stop(); jQuery("#first").load(url("data/test2.html"), function() { - equals( jQuery("#foo").html(), "foo", "Check if script evaluation has modified DOM"); - equals( testFoo, "foo", "Check if script was evaluated after load" ); + equal( jQuery("#foo").html(), "foo", "Check if script evaluation has modified DOM"); + equal( testFoo, "foo", "Check if script was evaluated after load" ); start(); }); @@ -1218,8 +1218,8 @@ test("load(String, Object, Function)", function() { jQuery("
").load(url("data/params_html.php"), { foo: 3, bar: "ok" }, function() { var $post = jQuery(this).find("#post"); - equals( $post.find("#foo").text(), "3", "Check if a hash of data is passed correctly"); - equals( $post.find("#bar").text(), "ok", "Check if a hash of data is passed correctly"); + equal( $post.find("#foo").text(), "3", "Check if a hash of data is passed correctly"); + equal( $post.find("#bar").text(), "ok", "Check if a hash of data is passed correctly"); start(); }); }); @@ -1230,8 +1230,8 @@ test("load(String, String, Function)", function() { jQuery("
").load(url("data/params_html.php"), "foo=3&bar=ok", function() { var $get = jQuery(this).find("#get"); - equals( $get.find("#foo").text(), "3", "Check if a string of data is passed correctly"); - equals( $get.find("#bar").text(), "ok", "Check if a of data is passed correctly"); + equal( $get.find("#foo").text(), "3", "Check if a string of data is passed correctly"); + equal( $get.find("#bar").text(), "ok", "Check if a of data is passed correctly"); start(); }); }); @@ -1259,8 +1259,8 @@ test("jQuery.get(String, Hash, Function) - parse xml and use text() on nodes", f jQuery("tab", xml).each(function() { content.push(jQuery(this).text()); }); - equals( content[0], "blabla", "Check first tab"); - equals( content[1], "blublu", "Check second tab"); + equal( content[0], "blabla", "Check first tab"); + equal( content[1], "blublu", "Check second tab"); start(); }); }); @@ -1269,7 +1269,7 @@ test("jQuery.getScript(String, Function) - with callback", function() { expect(3); stop(); jQuery.getScript(url("data/test.js"), function( data, _, jqXHR ) { - equals( foobar, "bar", "Check if script was evaluated" ); + equal( foobar, "bar", "Check if script was evaluated" ); strictEqual( data, jqXHR.responseText, "Same-domain script requests returns the source of the script (#8082)" ); setTimeout(start, 100); }); @@ -1574,7 +1574,7 @@ test("jQuery.ajax() - script, Remote with POST", function() { dataType: "script", success: function(data, status){ ok( foobar, "Script results returned (POST, no callback)" ); - equals( status, "success", "Script results returned (POST, no callback)" ); + equal( status, "success", "Script results returned (POST, no callback)" ); start(); }, error: function(xhr) { @@ -1615,7 +1615,7 @@ test("jQuery.ajax() - malformed JSON", function() { start(); }, error: function(xhr, msg, detailedMsg) { - equals( "parsererror", msg, "A parse error occurred." ); + equal( "parsererror", msg, "A parse error occurred." ); ok( /^(Invalid|SyntaxError|exception)/i.test(detailedMsg), "Detailed parsererror message provided" ); start(); } @@ -1654,10 +1654,10 @@ test("jQuery.ajax() - json by content-type", function() { data: { header: "json", json: "array" }, success: function( json ) { ok( json.length >= 2, "Check length"); - equals( json[0].name, "John", "Check JSON: first, name" ); - equals( json[0].age, 21, "Check JSON: first, age" ); - equals( json[1].name, "Peter", "Check JSON: second, name" ); - equals( json[1].age, 25, "Check JSON: second, age" ); + equal( json[0].name, "John", "Check JSON: first, name" ); + equal( json[0].age, 21, "Check JSON: first, age" ); + equal( json[1].name, "Peter", "Check JSON: second, name" ); + equal( json[1].age, 25, "Check JSON: second, age" ); start(); } }); @@ -1675,13 +1675,13 @@ test("jQuery.ajax() - json by content-type disabled with options", function() { json: false }, success: function( text ) { - equals( typeof text , "string" , "json wasn't auto-determined" ); + equal( typeof text , "string" , "json wasn't auto-determined" ); var json = jQuery.parseJSON( text ); ok( json.length >= 2, "Check length"); - equals( json[0].name, "John", "Check JSON: first, name" ); - equals( json[0].age, 21, "Check JSON: first, age" ); - equals( json[1].name, "Peter", "Check JSON: second, name" ); - equals( json[1].age, 25, "Check JSON: second, age" ); + equal( json[0].name, "John", "Check JSON: first, name" ); + equal( json[0].age, 21, "Check JSON: first, age" ); + equal( json[1].name, "Peter", "Check JSON: second, name" ); + equal( json[1].age, 25, "Check JSON: second, age" ); start(); } }); @@ -1692,10 +1692,10 @@ test("jQuery.getJSON(String, Hash, Function) - JSON array", function() { stop(); jQuery.getJSON(url("data/json.php"), {json: "array"}, function(json) { ok( json.length >= 2, "Check length"); - equals( json[0].name, "John", "Check JSON: first, name" ); - equals( json[0].age, 21, "Check JSON: first, age" ); - equals( json[1].name, "Peter", "Check JSON: second, name" ); - equals( json[1].age, 25, "Check JSON: second, age" ); + equal( json[0].name, "John", "Check JSON: first, name" ); + equal( json[0].age, 21, "Check JSON: first, age" ); + equal( json[1].name, "Peter", "Check JSON: second, name" ); + equal( json[1].age, 25, "Check JSON: second, age" ); start(); }); }); @@ -1705,8 +1705,8 @@ test("jQuery.getJSON(String, Function) - JSON object", function() { stop(); jQuery.getJSON(url("data/json.php"), function(json) { if (json && json.data) { - equals( json.data.lang, "en", "Check JSON: lang" ); - equals( json.data.length, 25, "Check JSON: length" ); + equal( json.data.lang, "en", "Check JSON: lang" ); + equal( json.data.length, 25, "Check JSON: length" ); } start(); }); @@ -1726,7 +1726,7 @@ test("jQuery.getJSON - Using Native JSON", function() { stop(); jQuery.getJSON(url("data/json.php"), function(json) { window.JSON = old; - equals( json, true, "Verifying return value" ); + equal( json, true, "Verifying return value" ); start(); }); }); @@ -1738,8 +1738,8 @@ test("jQuery.getJSON(String, Function) - JSON object with absolute url to local stop(); jQuery.getJSON(url(base + "data/json.php"), function(json) { - equals( json.data.lang, "en", "Check JSON: lang" ); - equals( json.data.length, 25, "Check JSON: length" ); + equal( json.data.lang, "en", "Check JSON: lang" ); + equal( json.data.length, 25, "Check JSON: length" ); start(); }); }); @@ -1750,8 +1750,8 @@ test("jQuery.post - data", 3, function() { jQuery.when( jQuery.post( url( "data/name.php" ), { xml: "5-2", length: 3 }, function( xml ) { jQuery( "math", xml ).each(function() { - equals( jQuery( "calculation", this ).text(), "5-2", "Check for XML" ); - equals( jQuery( "result", this ).text(), "3", "Check for XML" ); + equal( jQuery( "calculation", this ).text(), "5-2", "Check for XML" ); + equal( jQuery( "result", this ).text(), "3", "Check for XML" ); }); }), @@ -1781,16 +1781,16 @@ test("jQuery.post(String, Hash, Function) - simple with xml", function() { jQuery.post(url("data/name.php"), {xml: "5-2"}, function(xml){ jQuery("math", xml).each(function() { - equals( jQuery("calculation", this).text(), "5-2", "Check for XML" ); - equals( jQuery("result", this).text(), "3", "Check for XML" ); + equal( jQuery("calculation", this).text(), "5-2", "Check for XML" ); + equal( jQuery("result", this).text(), "3", "Check for XML" ); }); if ( ++done === 2 ) start(); }); jQuery.post(url("data/name.php?xml=5-2"), {}, function(xml){ jQuery("math", xml).each(function() { - equals( jQuery("calculation", this).text(), "5-2", "Check for XML" ); - equals( jQuery("result", this).text(), "3", "Check for XML" ); + equal( jQuery("calculation", this).text(), "5-2", "Check for XML" ); + equal( jQuery("result", this).text(), "3", "Check for XML" ); }); if ( ++done === 2 ) start(); }); @@ -1859,7 +1859,7 @@ test("jQuery.ajax - simple get", function() { type: "GET", url: url("data/name.php?name=foo"), success: function(msg){ - equals( msg, "bar", "Check for GET" ); + equal( msg, "bar", "Check for GET" ); start(); } }); @@ -1873,7 +1873,7 @@ test("jQuery.ajax - simple post", function() { url: url("data/name.php"), data: "name=peter", success: function(msg){ - equals( msg, "pan", "Check for POST" ); + equal( msg, "pan", "Check for POST" ); start(); } }); @@ -1885,7 +1885,7 @@ test("ajaxSetup()", function() { jQuery.ajaxSetup({ url: url("data/name.php?name=foo"), success: function(msg){ - equals( msg, "bar", "Check for GET" ); + equal( msg, "bar", "Check for GET" ); start(); } }); @@ -1900,7 +1900,7 @@ test("custom timeout does not set error message when timeout occurs, see #970", timeout: 500, error: function(request, status) { ok( status != null, "status shouldn't be null in error handler" ); - equals( "timeout", status ); + equal( "timeout", status ); start(); } }); @@ -1917,7 +1917,7 @@ test("data option: evaluate function values (#2806)", function() { } }, success: function(result) { - equals( result, "key=value" ); + equal( result, "key=value" ); start(); } }); @@ -1930,7 +1930,7 @@ test("data option: empty bodies for non-GET requests", function() { data: undefined, type: "post", success: function(result) { - equals( result, "" ); + equal( result, "" ); start(); } }); @@ -1952,7 +1952,7 @@ jQuery.each( { " (cache)": true, " (no cache)": false }, function( label, cache ifModified: true, cache: cache, success: function(data, status) { - equals(status, "success" ); + equal(status, "success" ); jQuery.ajax({ url: url, @@ -1963,7 +1963,7 @@ jQuery.each( { " (cache)": true, " (no cache)": false }, function( label, cache ok(jQuery.browser.opera, "Opera is incapable of doing .setRequestHeader('If-Modified-Since')."); ok(jQuery.browser.opera, "Opera is incapable of doing .setRequestHeader('If-Modified-Since')."); } else { - equals(status, "notmodified"); + equal(status, "notmodified"); ok(data == null, "response body should be empty"); } start(); @@ -1979,7 +1979,7 @@ jQuery.each( { " (cache)": true, " (no cache)": false }, function( label, cache }); }, error: function() { - equals(false, "error"); + equal(false, "error"); // Do this because opera simply refuses to implement 304 handling :( // A feature-driven way of detecting this would be appreciated // See: http://gist.github.com/599419 @@ -2001,7 +2001,7 @@ jQuery.each( { " (cache)": true, " (no cache)": false }, function( label, cache ifModified: true, cache: cache, success: function(data, status) { - equals(status, "success" ); + equal(status, "success" ); jQuery.ajax({ url: url, @@ -2012,7 +2012,7 @@ jQuery.each( { " (cache)": true, " (no cache)": false }, function( label, cache ok(jQuery.browser.opera, "Opera is incapable of doing .setRequestHeader('If-None-Match')."); ok(jQuery.browser.opera, "Opera is incapable of doing .setRequestHeader('If-None-Match')."); } else { - equals(status, "notmodified"); + equal(status, "notmodified"); ok(data == null, "response body should be empty"); } start(); diff --git a/test/unit/attributes.js b/test/unit/attributes.js index a9d79462d..f8305a28f 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -36,21 +36,21 @@ test("jQuery.propFix integrity test", function() { test("attr(String)", function() { expect(46); - equals( jQuery("#text1").attr("type"), "text", "Check for type attribute" ); - equals( jQuery("#radio1").attr("type"), "radio", "Check for type attribute" ); - equals( jQuery("#check1").attr("type"), "checkbox", "Check for type attribute" ); - equals( jQuery("#simon1").attr("rel"), "bookmark", "Check for rel attribute" ); - equals( jQuery("#google").attr("title"), "Google!", "Check for title attribute" ); - equals( jQuery("#mark").attr("hreflang"), "en", "Check for hreflang attribute" ); - equals( jQuery("#en").attr("lang"), "en", "Check for lang attribute" ); - equals( jQuery("#simon").attr("class"), "blog link", "Check for class attribute" ); - equals( jQuery("#name").attr("name"), "name", "Check for name attribute" ); - equals( jQuery("#text1").attr("name"), "action", "Check for name attribute" ); + equal( jQuery("#text1").attr("type"), "text", "Check for type attribute" ); + equal( jQuery("#radio1").attr("type"), "radio", "Check for type attribute" ); + equal( jQuery("#check1").attr("type"), "checkbox", "Check for type attribute" ); + equal( jQuery("#simon1").attr("rel"), "bookmark", "Check for rel attribute" ); + equal( jQuery("#google").attr("title"), "Google!", "Check for title attribute" ); + equal( jQuery("#mark").attr("hreflang"), "en", "Check for hreflang attribute" ); + equal( jQuery("#en").attr("lang"), "en", "Check for lang attribute" ); + equal( jQuery("#simon").attr("class"), "blog link", "Check for class attribute" ); + equal( jQuery("#name").attr("name"), "name", "Check for name attribute" ); + equal( jQuery("#text1").attr("name"), "action", "Check for name attribute" ); ok( jQuery("#form").attr("action").indexOf("formaction") >= 0, "Check for action attribute" ); - equals( jQuery("#text1").attr("value", "t").attr("value"), "t", "Check setting the value attribute" ); - equals( jQuery("
").attr("value"), "t", "Check setting custom attr named 'value' on a div" ); - equals( jQuery("#form").attr("blah", "blah").attr("blah"), "blah", "Set non-existant attribute on a form" ); - equals( jQuery("#foo").attr("height"), undefined, "Non existent height attribute should return undefined" ); + equal( jQuery("#text1").attr("value", "t").attr("value"), "t", "Check setting the value attribute" ); + equal( jQuery("
").attr("value"), "t", "Check setting custom attr named 'value' on a div" ); + equal( jQuery("#form").attr("blah", "blah").attr("blah"), "blah", "Set non-existant attribute on a form" ); + equal( jQuery("#foo").attr("height"), undefined, "Non existent height attribute should return undefined" ); // [7472] & [3113] (form contains an input with name="action" or name="id") var extras = jQuery("").appendTo("#testForm"); @@ -59,20 +59,20 @@ test("attr(String)", function() { equal( jQuery("#testForm").attr("target", "newTarget").attr("target"), "newTarget", "Set target successfully on a form" ); equal( jQuery("#testForm").removeAttr("id").attr("id"), undefined, "Retrieving id does not equal the input with name=id after id is removed [#7472]" ); // Bug #3685 (form contains input with name="name") - equals( jQuery("#testForm").attr("name"), undefined, "Retrieving name does not retrieve input with name=name" ); + equal( jQuery("#testForm").attr("name"), undefined, "Retrieving name does not retrieve input with name=name" ); extras.remove(); - equals( jQuery("#text1").attr("maxlength"), "30", "Check for maxlength attribute" ); - equals( jQuery("#text1").attr("maxLength"), "30", "Check for maxLength attribute" ); - equals( jQuery("#area1").attr("maxLength"), "30", "Check for maxLength attribute" ); + equal( jQuery("#text1").attr("maxlength"), "30", "Check for maxlength attribute" ); + equal( jQuery("#text1").attr("maxLength"), "30", "Check for maxLength attribute" ); + equal( jQuery("#area1").attr("maxLength"), "30", "Check for maxLength attribute" ); // using innerHTML in IE causes href attribute to be serialized to the full path jQuery("").attr({ "id": "tAnchor5", "href": "#5" }).appendTo("#qunit-fixture"); - equals( jQuery("#tAnchor5").attr("href"), "#5", "Check for non-absolute href (an anchor)" ); + equal( jQuery("#tAnchor5").attr("href"), "#5", "Check for non-absolute href (an anchor)" ); // list attribute is readonly by default in browsers that support it jQuery("#list-test").attr("list", "datalist"); - equals( jQuery("#list-test").attr("list"), "datalist", "Check setting list attribute" ); + equal( jQuery("#list-test").attr("list"), "datalist", "Check setting list attribute" ); // Related to [5574] and [5683] var body = document.body, $body = jQuery(body); @@ -80,10 +80,10 @@ test("attr(String)", function() { strictEqual( $body.attr("foo"), undefined, "Make sure that a non existent attribute returns undefined" ); body.setAttribute("foo", "baz"); - equals( $body.attr("foo"), "baz", "Make sure the dom attribute is retrieved when no expando is found" ); + equal( $body.attr("foo"), "baz", "Make sure the dom attribute is retrieved when no expando is found" ); $body.attr("foo","cool"); - equals( $body.attr("foo"), "cool", "Make sure that setting works well when both expando and dom attribute are available" ); + equal( $body.attr("foo"), "cool", "Make sure that setting works well when both expando and dom attribute are available" ); body.removeAttribute("foo"); // Cleanup @@ -94,8 +94,8 @@ test("attr(String)", function() { equal( jQuery( option ).attr("selected"), "selected", "Make sure that a single option is selected, even when in an optgroup." ); var $img = jQuery("").appendTo("body"); - equals( $img.attr("width"), "215", "Retrieve width attribute an an element with display:none." ); - equals( $img.attr("height"), "53", "Retrieve height attribute an an element with display:none." ); + equal( $img.attr("width"), "215", "Retrieve width attribute an an element with display:none." ); + equal( $img.attr("height"), "53", "Retrieve height attribute an an element with display:none." ); // Check for style support ok( !!~jQuery("#dl").attr("style").indexOf("position"), "Check style attribute getter, also normalize css props to lowercase" ); @@ -103,12 +103,12 @@ test("attr(String)", function() { // Check value on button element (#1954) var $button = jQuery("").insertAfter("#button"); - equals( $button.attr("value"), "foobar", "Value retrieval on a button does not return innerHTML" ); - equals( $button.attr("value", "baz").html(), "text", "Setting the value does not change innerHTML" ); + equal( $button.attr("value"), "foobar", "Value retrieval on a button does not return innerHTML" ); + equal( $button.attr("value", "baz").html(), "text", "Setting the value does not change innerHTML" ); // Attributes with a colon on a table element (#1591) - equals( jQuery("#table").attr("test:attrib"), undefined, "Retrieving a non-existent attribute on a table with a colon does not throw an error." ); - equals( jQuery("#table").attr("test:attrib", "foobar").attr("test:attrib"), "foobar", "Setting an attribute on a table with a colon does not throw an error." ); + equal( jQuery("#table").attr("test:attrib"), undefined, "Retrieving a non-existent attribute on a table with a colon does not throw an error." ); + equal( jQuery("#table").attr("test:attrib", "foobar").attr("test:attrib"), "foobar", "Setting an attribute on a table with a colon does not throw an error." ); var $form = jQuery("
").appendTo("#qunit-fixture"); equal( $form.attr("class"), "something", "Retrieve the class attribute on a form." ); @@ -142,8 +142,8 @@ if ( !isLocal ) { test("attr(String, Function)", function() { expect(2); - equals( jQuery("#text1").attr("value", function() { return this.id; })[0].value, "text1", "Set value from id" ); - equals( jQuery("#text1").attr("title", function(i) { return i; }).attr("title"), "0", "Set value with an index"); + equal( jQuery("#text1").attr("value", function() { return this.id; })[0].value, "text1", "Set value from id" ); + equal( jQuery("#text1").attr("title", function(i) { return i; }).attr("title"), "0", "Set value with an index"); }); test("attr(Hash)", function() { @@ -153,8 +153,8 @@ test("attr(Hash)", function() { if ( this.getAttribute("foo") != "baz" && this.getAttribute("zoo") != "ping" ) pass = false; }); ok( pass, "Set Multiple Attributes" ); - equals( jQuery("#text1").attr({value: function() { return this.id; }})[0].value, "text1", "Set attribute to computed value #1" ); - equals( jQuery("#text1").attr({title: function(i) { return i; }}).attr("title"), "0", "Set attribute to computed value #2"); + equal( jQuery("#text1").attr({value: function() { return this.id; }})[0].value, "text1", "Set attribute to computed value #1" ); + equal( jQuery("#text1").attr({title: function(i) { return i; }}).attr("title"), "0", "Set attribute to computed value #2"); }); test("attr(String, Object)", function() { @@ -170,43 +170,43 @@ test("attr(String, Object)", function() { } } - equals( fail, false, "Set Attribute, the #" + fail + " element didn't get the attribute 'foo'" ); + equal( fail, false, "Set Attribute, the #" + fail + " element didn't get the attribute 'foo'" ); ok( jQuery("#foo").attr({ "width": null }), "Try to set an attribute to nothing" ); jQuery("#name").attr("name", "something"); - equals( jQuery("#name").attr("name"), "something", "Set name attribute" ); + equal( jQuery("#name").attr("name"), "something", "Set name attribute" ); jQuery("#name").attr("name", null); - equals( jQuery("#name").attr("name"), undefined, "Remove name attribute" ); + equal( jQuery("#name").attr("name"), undefined, "Remove name attribute" ); var $input = jQuery("", { name: "something", id: "specified" }); equal( $input.attr("name"), "something", "Check element creation gets/sets the name attribute." ); equal( $input.attr("id"), "specified", "Check element creation gets/sets the id attribute." ); jQuery("#check2").prop("checked", true).prop("checked", false).attr("checked", true); - equals( document.getElementById("check2").checked, true, "Set checked attribute" ); - equals( jQuery("#check2").prop("checked"), true, "Set checked attribute" ); - equals( jQuery("#check2").attr("checked"), "checked", "Set checked attribute" ); + equal( document.getElementById("check2").checked, true, "Set checked attribute" ); + equal( jQuery("#check2").prop("checked"), true, "Set checked attribute" ); + equal( jQuery("#check2").attr("checked"), "checked", "Set checked attribute" ); jQuery("#check2").attr("checked", false); - equals( document.getElementById("check2").checked, false, "Set checked attribute" ); - equals( jQuery("#check2").prop("checked"), false, "Set checked attribute" ); - equals( jQuery("#check2").attr("checked"), undefined, "Set checked attribute" ); + equal( document.getElementById("check2").checked, false, "Set checked attribute" ); + equal( jQuery("#check2").prop("checked"), false, "Set checked attribute" ); + equal( jQuery("#check2").attr("checked"), undefined, "Set checked attribute" ); jQuery("#text1").attr("readonly", true); - equals( document.getElementById("text1").readOnly, true, "Set readonly attribute" ); - equals( jQuery("#text1").prop("readOnly"), true, "Set readonly attribute" ); - equals( jQuery("#text1").attr("readonly"), "readonly", "Set readonly attribute" ); + equal( document.getElementById("text1").readOnly, true, "Set readonly attribute" ); + equal( jQuery("#text1").prop("readOnly"), true, "Set readonly attribute" ); + equal( jQuery("#text1").attr("readonly"), "readonly", "Set readonly attribute" ); jQuery("#text1").attr("readonly", false); - equals( document.getElementById("text1").readOnly, false, "Set readonly attribute" ); - equals( jQuery("#text1").prop("readOnly"), false, "Set readonly attribute" ); - equals( jQuery("#text1").attr("readonly"), undefined, "Set readonly attribute" ); + equal( document.getElementById("text1").readOnly, false, "Set readonly attribute" ); + equal( jQuery("#text1").prop("readOnly"), false, "Set readonly attribute" ); + equal( jQuery("#text1").attr("readonly"), undefined, "Set readonly attribute" ); jQuery("#check2").prop("checked", true); - equals( document.getElementById("check2").checked, true, "Set checked attribute" ); - equals( jQuery("#check2").prop("checked"), true, "Set checked attribute" ); - equals( jQuery("#check2").attr("checked"), "checked", "Set checked attribute" ); + equal( document.getElementById("check2").checked, true, "Set checked attribute" ); + equal( jQuery("#check2").prop("checked"), true, "Set checked attribute" ); + equal( jQuery("#check2").attr("checked"), "checked", "Set checked attribute" ); jQuery("#check2").prop("checked", false); - equals( document.getElementById("check2").checked, false, "Set checked attribute" ); - equals( jQuery("#check2").prop("checked"), false, "Set checked attribute" ); - equals( jQuery("#check2").attr("checked"), undefined, "Set checked attribute" ); + equal( document.getElementById("check2").checked, false, "Set checked attribute" ); + equal( jQuery("#check2").prop("checked"), false, "Set checked attribute" ); + equal( jQuery("#check2").attr("checked"), undefined, "Set checked attribute" ); jQuery("#check2").attr("checked", "checked"); equal( document.getElementById("check2").checked, true, "Set checked attribute with 'checked'" ); @@ -221,18 +221,18 @@ test("attr(String, Object)", function() { equal( $radios.attr("checked"), $radios[0].checked ? "checked" : undefined, "Known booleans do not fall back to attribute presence (#10278)"); jQuery("#text1").prop("readOnly", true); - equals( document.getElementById("text1").readOnly, true, "Set readonly attribute" ); - equals( jQuery("#text1").prop("readOnly"), true, "Set readonly attribute" ); - equals( jQuery("#text1").attr("readonly"), "readonly", "Set readonly attribute" ); + equal( document.getElementById("text1").readOnly, true, "Set readonly attribute" ); + equal( jQuery("#text1").prop("readOnly"), true, "Set readonly attribute" ); + equal( jQuery("#text1").attr("readonly"), "readonly", "Set readonly attribute" ); jQuery("#text1").prop("readOnly", false); - equals( document.getElementById("text1").readOnly, false, "Set readonly attribute" ); - equals( jQuery("#text1").prop("readOnly"), false, "Set readonly attribute" ); - equals( jQuery("#text1").attr("readonly"), undefined, "Set readonly attribute" ); + equal( document.getElementById("text1").readOnly, false, "Set readonly attribute" ); + equal( jQuery("#text1").prop("readOnly"), false, "Set readonly attribute" ); + equal( jQuery("#text1").attr("readonly"), undefined, "Set readonly attribute" ); jQuery("#name").attr("maxlength", "5"); - equals( document.getElementById("name").maxLength, 5, "Set maxlength attribute" ); + equal( document.getElementById("name").maxLength, 5, "Set maxlength attribute" ); jQuery("#name").attr("maxLength", "10"); - equals( document.getElementById("name").maxLength, 10, "Set maxlength attribute" ); + equal( document.getElementById("name").maxLength, 10, "Set maxlength attribute" ); // HTML5 boolean attributes var $text = jQuery("#text1").attr({ @@ -258,7 +258,7 @@ test("attr(String, Object)", function() { $text.removeData("something").removeData("another").removeAttr("aria-disabled"); jQuery("#foo").attr("contenteditable", true); - equals( jQuery("#foo").attr("contenteditable"), "true", "Enumerated attributes are set properly" ); + equal( jQuery("#foo").attr("contenteditable"), "true", "Enumerated attributes are set properly" ); var attributeNode = document.createAttribute("irrelevant"), commentNode = document.createComment("some comment"), @@ -280,27 +280,27 @@ test("attr(String, Object)", function() { var table = jQuery("#table").append("cellcellcellcellcell"), td = table.find("td:first"); td.attr("rowspan", "2"); - equals( td[0].rowSpan, 2, "Check rowspan is correctly set" ); + equal( td[0].rowSpan, 2, "Check rowspan is correctly set" ); td.attr("colspan", "2"); - equals( td[0].colSpan, 2, "Check colspan is correctly set" ); + equal( td[0].colSpan, 2, "Check colspan is correctly set" ); table.attr("cellspacing", "2"); - equals( table[0].cellSpacing, "2", "Check cellspacing is correctly set" ); + equal( table[0].cellSpacing, "2", "Check cellspacing is correctly set" ); - equals( jQuery("#area1").attr("value"), "foobar", "Value attribute retrieves the property for backwards compatibility." ); + equal( jQuery("#area1").attr("value"), "foobar", "Value attribute retrieves the property for backwards compatibility." ); // for #1070 jQuery("#name").attr("someAttr", "0"); - equals( jQuery("#name").attr("someAttr"), "0", "Set attribute to a string of \"0\"" ); + equal( jQuery("#name").attr("someAttr"), "0", "Set attribute to a string of \"0\"" ); jQuery("#name").attr("someAttr", 0); - equals( jQuery("#name").attr("someAttr"), "0", "Set attribute to the number 0" ); + equal( jQuery("#name").attr("someAttr"), "0", "Set attribute to the number 0" ); jQuery("#name").attr("someAttr", 1); - equals( jQuery("#name").attr("someAttr"), "1", "Set attribute to the number 1" ); + equal( jQuery("#name").attr("someAttr"), "1", "Set attribute to the number 1" ); // using contents will get comments regular, text, and comment nodes var j = jQuery("#nonnodes").contents(); j.attr("name", "attrvalue"); - equals( j.attr("name"), "attrvalue", "Check node,textnode,comment for attr" ); + equal( j.attr("name"), "attrvalue", "Check node,textnode,comment for attr" ); j.removeAttr("name"); // Type @@ -312,7 +312,7 @@ test("attr(String, Object)", function() { thrown = true; } ok( thrown, "Exception thrown when trying to change type property" ); - equals( type, jQuery("#check2").attr("type"), "Verify that you can't change the type of an input element" ); + equal( type, jQuery("#check2").attr("type"), "Verify that you can't change the type of an input element" ); var check = document.createElement("input"); thrown = true; @@ -322,7 +322,7 @@ test("attr(String, Object)", function() { thrown = false; } ok( thrown, "Exception thrown when trying to change type property" ); - equals( "checkbox", jQuery(check).attr("type"), "Verify that you can change the type of an input element that isn't in the DOM" ); + equal( "checkbox", jQuery(check).attr("type"), "Verify that you can change the type of an input element that isn't in the DOM" ); check = jQuery(""); thrown = true; @@ -332,7 +332,7 @@ test("attr(String, Object)", function() { thrown = false; } ok( thrown, "Exception thrown when trying to change type property" ); - equals( "checkbox", check.attr("type"), "Verify that you can change the type of an input element that isn't in the DOM" ); + equal( "checkbox", check.attr("type"), "Verify that you can change the type of an input element that isn't in the DOM" ); var button = jQuery("#button"); thrown = false; @@ -342,16 +342,16 @@ test("attr(String, Object)", function() { thrown = true; } ok( thrown, "Exception thrown when trying to change type property" ); - equals( "button", button.attr("type"), "Verify that you can't change the type of a button element" ); + equal( "button", button.attr("type"), "Verify that you can't change the type of a button element" ); var $radio = jQuery("", { "value": "sup", "type": "radio" }).appendTo("#testForm"); - equals( $radio.val(), "sup", "Value is not reset when type is set after value on a radio" ); + equal( $radio.val(), "sup", "Value is not reset when type is set after value on a radio" ); // Setting attributes on svg elements (bug #3116) var $svg = jQuery("" + "" + "").appendTo("body"); - equals( $svg.attr("cx", 100).attr("cx"), "100", "Set attribute on svg element" ); + equal( $svg.attr("cx", 100).attr("cx"), "100", "Set attribute on svg element" ); $svg.remove(); }); @@ -363,16 +363,16 @@ test("attr(jquery_method)", function(){ // one at a time $elem.attr({html: "foo"}, true); - equals( elem.innerHTML, "foo", "attr(html)"); + equal( elem.innerHTML, "foo", "attr(html)"); $elem.attr({text: "bar"}, true); - equals( elem.innerHTML, "bar", "attr(text)"); + equal( elem.innerHTML, "bar", "attr(text)"); $elem.attr({css: {color: "red"}}, true); ok( /^(#ff0000|red)$/i.test(elem.style.color), "attr(css)"); $elem.attr({height: 10}, true); - equals( elem.style.height, "10px", "attr(height)"); + equal( elem.style.height, "10px", "attr(height)"); // Multiple attributes @@ -381,9 +381,9 @@ test("attr(jquery_method)", function(){ css:{ paddingLeft:1, paddingRight:1 } }, true); - equals( elem.style.width, "10px", "attr({...})"); - equals( elem.style.paddingLeft, "1px", "attr({...})"); - equals( elem.style.paddingRight, "1px", "attr({...})"); + equal( elem.style.width, "10px", "attr({...})"); + equal( elem.style.paddingLeft, "1px", "attr({...})"); + equal( elem.style.paddingRight, "1px", "attr({...})"); }); if ( !isLocal ) { @@ -395,8 +395,8 @@ if ( !isLocal ) { jQuery( "tab", xml ).each(function() { titles.push( jQuery(this).attr("title") ); }); - equals( titles[0], "Location", "attr() in XML context: Check first title" ); - equals( titles[1], "Users", "attr() in XML context: Check second title" ); + equal( titles[0], "Location", "attr() in XML context: Check first title" ); + equal( titles[1], "Users", "attr() in XML context: Check second title" ); start(); }); }); @@ -406,55 +406,55 @@ test("attr('tabindex')", function() { expect(8); // elements not natively tabbable - equals(jQuery("#listWithTabIndex").attr("tabindex"), 5, "not natively tabbable, with tabindex set to 0"); - equals(jQuery("#divWithNoTabIndex").attr("tabindex"), undefined, "not natively tabbable, no tabindex set"); + equal(jQuery("#listWithTabIndex").attr("tabindex"), 5, "not natively tabbable, with tabindex set to 0"); + equal(jQuery("#divWithNoTabIndex").attr("tabindex"), undefined, "not natively tabbable, no tabindex set"); // anchor with href - equals(jQuery("#linkWithNoTabIndex").attr("tabindex"), 0, "anchor with href, no tabindex set"); - equals(jQuery("#linkWithTabIndex").attr("tabindex"), 2, "anchor with href, tabindex set to 2"); - equals(jQuery("#linkWithNegativeTabIndex").attr("tabindex"), -1, "anchor with href, tabindex set to -1"); + equal(jQuery("#linkWithNoTabIndex").attr("tabindex"), 0, "anchor with href, no tabindex set"); + equal(jQuery("#linkWithTabIndex").attr("tabindex"), 2, "anchor with href, tabindex set to 2"); + equal(jQuery("#linkWithNegativeTabIndex").attr("tabindex"), -1, "anchor with href, tabindex set to -1"); // anchor without href - equals(jQuery("#linkWithNoHrefWithNoTabIndex").attr("tabindex"), undefined, "anchor without href, no tabindex set"); - equals(jQuery("#linkWithNoHrefWithTabIndex").attr("tabindex"), 1, "anchor without href, tabindex set to 2"); - equals(jQuery("#linkWithNoHrefWithNegativeTabIndex").attr("tabindex"), -1, "anchor without href, no tabindex set"); + equal(jQuery("#linkWithNoHrefWithNoTabIndex").attr("tabindex"), undefined, "anchor without href, no tabindex set"); + equal(jQuery("#linkWithNoHrefWithTabIndex").attr("tabindex"), 1, "anchor without href, tabindex set to 2"); + equal(jQuery("#linkWithNoHrefWithNegativeTabIndex").attr("tabindex"), -1, "anchor without href, no tabindex set"); }); test("attr('tabindex', value)", function() { expect(9); var element = jQuery("#divWithNoTabIndex"); - equals(element.attr("tabindex"), undefined, "start with no tabindex"); + equal(element.attr("tabindex"), undefined, "start with no tabindex"); // set a positive string element.attr("tabindex", "1"); - equals(element.attr("tabindex"), 1, "set tabindex to 1 (string)"); + equal(element.attr("tabindex"), 1, "set tabindex to 1 (string)"); // set a zero string element.attr("tabindex", "0"); - equals(element.attr("tabindex"), 0, "set tabindex to 0 (string)"); + equal(element.attr("tabindex"), 0, "set tabindex to 0 (string)"); // set a negative string element.attr("tabindex", "-1"); - equals(element.attr("tabindex"), -1, "set tabindex to -1 (string)"); + equal(element.attr("tabindex"), -1, "set tabindex to -1 (string)"); // set a positive number element.attr("tabindex", 1); - equals(element.attr("tabindex"), 1, "set tabindex to 1 (number)"); + equal(element.attr("tabindex"), 1, "set tabindex to 1 (number)"); // set a zero number element.attr("tabindex", 0); - equals(element.attr("tabindex"), 0, "set tabindex to 0 (number)"); + equal(element.attr("tabindex"), 0, "set tabindex to 0 (number)"); // set a negative number element.attr("tabindex", -1); - equals(element.attr("tabindex"), -1, "set tabindex to -1 (number)"); + equal(element.attr("tabindex"), -1, "set tabindex to -1 (number)"); element = jQuery("#linkWithTabIndex"); - equals(element.attr("tabindex"), 2, "start with tabindex 2"); + equal(element.attr("tabindex"), 2, "start with tabindex 2"); element.attr("tabindex", -1); - equals(element.attr("tabindex"), -1, "set negative tabindex"); + equal(element.attr("tabindex"), -1, "set negative tabindex"); }); test("removeAttr(String)", function() { @@ -484,32 +484,32 @@ test("removeAttr(String)", function() { test("prop(String, Object)", function() { expect(31); - equals( jQuery("#text1").prop("value"), "Test", "Check for value attribute" ); - equals( jQuery("#text1").prop("value", "Test2").prop("defaultValue"), "Test", "Check for defaultValue attribute" ); - equals( jQuery("#select2").prop("selectedIndex"), 3, "Check for selectedIndex attribute" ); - equals( jQuery("#foo").prop("nodeName").toUpperCase(), "DIV", "Check for nodeName attribute" ); - equals( jQuery("#foo").prop("tagName").toUpperCase(), "DIV", "Check for tagName attribute" ); - equals( jQuery(""); $select1.val(valueObj( 4 )); - equals( $select1.val(), "4", "Should be possible to set the val() to a newly created option" ); + equal( $select1.val(), "4", "Should be possible to set the val() to a newly created option" ); // using contents will get comments regular, text, and comment nodes var j = jQuery("#nonnodes").contents(); j.val(valueObj( "asdf" )); - equals( j.val(), "asdf", "Check node,textnode,comment with val()" ); + equal( j.val(), "asdf", "Check node,textnode,comment with val()" ); j.removeAttr("value"); } @@ -802,49 +802,49 @@ test("val(Function) with incoming value", function() { var oldVal = jQuery("#text1").val(); jQuery("#text1").val(function(i, val) { - equals( val, oldVal, "Make sure the incoming value is correct." ); + equal( val, oldVal, "Make sure the incoming value is correct." ); return "test"; }); - equals( document.getElementById("text1").value, "test", "Check for modified (via val(String)) value of input element" ); + equal( document.getElementById("text1").value, "test", "Check for modified (via val(String)) value of input element" ); oldVal = jQuery("#text1").val(); jQuery("#text1").val(function(i, val) { - equals( val, oldVal, "Make sure the incoming value is correct." ); + equal( val, oldVal, "Make sure the incoming value is correct." ); return 67; }); - equals( document.getElementById("text1").value, "67", "Check for modified (via val(Number)) value of input element" ); + equal( document.getElementById("text1").value, "67", "Check for modified (via val(Number)) value of input element" ); oldVal = jQuery("#select1").val(); jQuery("#select1").val(function(i, val) { - equals( val, oldVal, "Make sure the incoming value is correct." ); + equal( val, oldVal, "Make sure the incoming value is correct." ); return "3"; }); - equals( jQuery("#select1").val(), "3", "Check for modified (via val(String)) value of select element" ); + equal( jQuery("#select1").val(), "3", "Check for modified (via val(String)) value of select element" ); oldVal = jQuery("#select1").val(); jQuery("#select1").val(function(i, val) { - equals( val, oldVal, "Make sure the incoming value is correct." ); + equal( val, oldVal, "Make sure the incoming value is correct." ); return 2; }); - equals( jQuery("#select1").val(), "2", "Check for modified (via val(Number)) value of select element" ); + equal( jQuery("#select1").val(), "2", "Check for modified (via val(Number)) value of select element" ); jQuery("#select1").append(""); oldVal = jQuery("#select1").val(); jQuery("#select1").val(function(i, val) { - equals( val, oldVal, "Make sure the incoming value is correct." ); + equal( val, oldVal, "Make sure the incoming value is correct." ); return 4; }); - equals( jQuery("#select1").val(), "4", "Should be possible to set the val() to a newly created option" ); + equal( jQuery("#select1").val(), "4", "Should be possible to set the val() to a newly created option" ); }); // testing if a form.reset() breaks a subsequent call to a select element's .val() (in IE only) @@ -861,7 +861,7 @@ test("val(select) after form.reset() (Bug #2551)", function() { equal( jQuery("#kkk").val(), "cf", "Check value of select after form reset." ); // re-verify the multi-select is not broken (after form.reset) by our fix for single-select - same( jQuery("#select3").val(), ["1", "2"], "Call val() on a multiple=\"multiple\" select" ); + deepEqual( jQuery("#select3").val(), ["1", "2"], "Call val() on a multiple=\"multiple\" select" ); jQuery("#kk").remove(); }); @@ -887,15 +887,15 @@ var testAddClass = function(valueObj) { div = jQuery("
"); div.addClass( valueObj("test") ); - equals( div.attr("class"), "test", "Make sure there's no extra whitespace." ); + equal( div.attr("class"), "test", "Make sure there's no extra whitespace." ); div.attr("class", " foo"); div.addClass( valueObj("test") ); - equals( div.attr("class"), "foo test", "Make sure there's no extra whitespace." ); + equal( div.attr("class"), "foo test", "Make sure there's no extra whitespace." ); div.attr("class", "foo"); div.addClass( valueObj("bar baz") ); - equals( div.attr("class"), "foo bar baz", "Make sure there isn't too much trimming." ); + equal( div.attr("class"), "foo bar baz", "Make sure there isn't too much trimming." ); div.removeClass(); div.addClass( valueObj("foo") ).addClass( valueObj("foo") ); @@ -927,7 +927,7 @@ test("addClass(Function) with incoming value", function() { div.addClass(function(i, val) { if ( this.id !== "_firebugConsole") { - equals( val, old[i], "Make sure the incoming value is correct." ); + equal( val, old[i], "Make sure the incoming value is correct." ); return "test"; } }); @@ -975,12 +975,12 @@ var testRemoveClass = function(valueObj) { div.className = " test foo "; jQuery(div).removeClass( valueObj("foo") ); - equals( div.className, "test", "Make sure remaining className is trimmed." ); + equal( div.className, "test", "Make sure remaining className is trimmed." ); div.className = " test "; jQuery(div).removeClass( valueObj("test") ); - equals( div.className, "", "Make sure there is nothing left after everything is removed." ); + equal( div.className, "", "Make sure there is nothing left after everything is removed." ); }; test("removeClass(String) - simple", function() { @@ -1000,7 +1000,7 @@ test("removeClass(Function) with incoming value", function() { $divs.removeClass(function(i, val) { if ( this.id !== "_firebugConsole" ) { - equals( val, old[i], "Make sure the incoming value is correct." ); + equal( val, old[i], "Make sure the incoming value is correct." ); return "test"; } }); @@ -1127,17 +1127,17 @@ test("addClass, removeClass, hasClass", function() { var jq = jQuery("

Hi

"), x = jq[0]; jq.addClass("hi"); - equals( x.className, "hi", "Check single added class" ); + equal( x.className, "hi", "Check single added class" ); jq.addClass("foo bar"); - equals( x.className, "hi foo bar", "Check more added classes" ); + equal( x.className, "hi foo bar", "Check more added classes" ); jq.removeClass(); - equals( x.className, "", "Remove all classes" ); + equal( x.className, "", "Remove all classes" ); jq.addClass("hi foo bar"); jq.removeClass("foo"); - equals( x.className, "hi bar", "Check removal of one class" ); + equal( x.className, "hi bar", "Check removal of one class" ); ok( jq.hasClass("hi"), "Check has1" ); ok( jq.hasClass("bar"), "Check has2" ); diff --git a/test/unit/callbacks.js b/test/unit/callbacks.js index a1935e743..03d969319 100644 --- a/test/unit/callbacks.js +++ b/test/unit/callbacks.js @@ -69,7 +69,7 @@ jQuery.each( tests, function( flags, resultString ) { output = "X"; cblist = jQuery.Callbacks( flags ); cblist.add(function() { - equals( this, window, "Basic binding and firing (context)" ); + equal( this, window, "Basic binding and firing (context)" ); output += Array.prototype.join.call( arguments, "" ); }); cblist.fireWith( window, [ "A", "B" ] ); @@ -79,7 +79,7 @@ jQuery.each( tests, function( flags, resultString ) { output = ""; cblist = jQuery.Callbacks( flags ); cblist.add(function() { - equals( this, window, "fireWith with no arguments (context is window)" ); + equal( this, window, "fireWith with no arguments (context is window)" ); strictEqual( arguments.length, 0, "fireWith with no arguments (no arguments)" ); }); cblist.fireWith(); diff --git a/test/unit/core.js b/test/unit/core.js index 0756e7947..252f08d57 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -16,21 +16,21 @@ test("jQuery()", function() { // Basic constructor's behavior - equals( jQuery().length, 0, "jQuery() === jQuery([])" ); - equals( jQuery(undefined).length, 0, "jQuery(undefined) === jQuery([])" ); - equals( jQuery(null).length, 0, "jQuery(null) === jQuery([])" ); - equals( jQuery("").length, 0, "jQuery('') === jQuery([])" ); - equals( jQuery("#").length, 0, "jQuery('#') === jQuery([])" ); + equal( jQuery().length, 0, "jQuery() === jQuery([])" ); + equal( jQuery(undefined).length, 0, "jQuery(undefined) === jQuery([])" ); + equal( jQuery(null).length, 0, "jQuery(null) === jQuery([])" ); + equal( jQuery("").length, 0, "jQuery('') === jQuery([])" ); + equal( jQuery("#").length, 0, "jQuery('#') === jQuery([])" ); var obj = jQuery("div"); - equals( jQuery(obj).selector, "div", "jQuery(jQueryObj) == jQueryObj" ); + equal( jQuery(obj).selector, "div", "jQuery(jQueryObj) == jQueryObj" ); // can actually yield more than one, when iframes are included, the window is an array as well - equals( jQuery(window).length, 1, "Correct number of elements generated for jQuery(window)" ); + equal( jQuery(window).length, 1, "Correct number of elements generated for jQuery(window)" ); var main = jQuery("#qunit-fixture"); - same( jQuery("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" ); + deepEqual( jQuery("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" ); /* // disabled since this test was doing nothing. i tried to fix it but i'm not sure @@ -38,7 +38,7 @@ test("jQuery()", function() { // make sure this is handled var crlfContainer = jQuery('

\r\n

'); var x = crlfContainer.contents().get(0).nodeValue; - equals( x, what???, "Check for \\r and \\n in jQuery()" ); + equal( x, what???, "Check for \\r and \\n in jQuery()" ); */ /* // Disabled until we add this functionality in @@ -51,18 +51,18 @@ test("jQuery()", function() { ok( pass, "jQuery('<tag>') needs optional document parameter to ease cross-frame DOM wrangling, see #968" );*/ var code = jQuery(""); - equals( code.length, 1, "Correct number of elements generated for code" ); - equals( code.parent().length, 0, "Make sure that the generated HTML has no parent." ); + equal( code.length, 1, "Correct number of elements generated for code" ); + equal( code.parent().length, 0, "Make sure that the generated HTML has no parent." ); var img = jQuery(""); - equals( img.length, 1, "Correct number of elements generated for img" ); - equals( img.parent().length, 0, "Make sure that the generated HTML has no parent." ); + equal( img.length, 1, "Correct number of elements generated for img" ); + equal( img.parent().length, 0, "Make sure that the generated HTML has no parent." ); var div = jQuery("

"); - equals( div.length, 4, "Correct number of elements generated for div hr code b" ); - equals( div.parent().length, 0, "Make sure that the generated HTML has no parent." ); + equal( div.length, 4, "Correct number of elements generated for div hr code b" ); + equal( div.parent().length, 0, "Make sure that the generated HTML has no parent." ); - equals( jQuery([1,2,3]).get(1), 2, "Test passing an array to the factory" ); + equal( jQuery([1,2,3]).get(1), 2, "Test passing an array to the factory" ); - equals( jQuery(document.body).get(0), jQuery("body").get(0), "Test passing an html node to the factory" ); + equal( jQuery(document.body).get(0), jQuery("body").get(0), "Test passing an html node to the factory" ); var exec = false; @@ -75,13 +75,13 @@ test("jQuery()", function() { id: "test3" }); - equals( elem[0].style.width, "10px", "jQuery() quick setter width"); - equals( elem[0].style.paddingLeft, "1px", "jQuery quick setter css"); - equals( elem[0].style.paddingRight, "1px", "jQuery quick setter css"); - equals( elem[0].childNodes.length, 1, "jQuery quick setter text"); - equals( elem[0].firstChild.nodeValue, "test", "jQuery quick setter text"); - equals( elem[0].className, "test2", "jQuery() quick setter class"); - equals( elem[0].id, "test3", "jQuery() quick setter id"); + equal( elem[0].style.width, "10px", "jQuery() quick setter width"); + equal( elem[0].style.paddingLeft, "1px", "jQuery quick setter css"); + equal( elem[0].style.paddingRight, "1px", "jQuery quick setter css"); + equal( elem[0].childNodes.length, 1, "jQuery quick setter text"); + equal( elem[0].firstChild.nodeValue, "test", "jQuery quick setter text"); + equal( elem[0].className, "test2", "jQuery() quick setter class"); + equal( elem[0].id, "test3", "jQuery() quick setter id"); exec = true; elem.click(); @@ -92,21 +92,21 @@ test("jQuery()", function() { for ( var i = 0; i < 3; ++i ) { elem = jQuery(""); } - equals( elem[0].defaultValue, "TEST", "Ensure cached nodes are cloned properly (Bug #6655)" ); + equal( elem[0].defaultValue, "TEST", "Ensure cached nodes are cloned properly (Bug #6655)" ); // manually clean up detached elements elem.remove(); - equals( jQuery("
").length, 1, "Make sure whitespace is trimmed." ); - equals( jQuery(" a
b ").length, 1, "Make sure whitespace and other characters are trimmed." ); + equal( jQuery("
").length, 1, "Make sure whitespace is trimmed." ); + equal( jQuery(" a
b ").length, 1, "Make sure whitespace and other characters are trimmed." ); var long = ""; for ( var i = 0; i < 128; i++ ) { long += "12345678"; } - equals( jQuery("
" + long + "
").length, 1, "Make sure whitespace is trimmed on long strings." ); - equals( jQuery(" a
" + long + "
b ").length, 1, "Make sure whitespace and other characters are trimmed on long strings." ); + equal( jQuery("
" + long + "
").length, 1, "Make sure whitespace is trimmed on long strings." ); + equal( jQuery(" a
" + long + "
b ").length, 1, "Make sure whitespace and other characters are trimmed on long strings." ); }); test("selector state", function() { @@ -115,68 +115,68 @@ test("selector state", function() { var test; test = jQuery(undefined); - equals( test.selector, "", "Empty jQuery Selector" ); - equals( test.context, undefined, "Empty jQuery Context" ); + equal( test.selector, "", "Empty jQuery Selector" ); + equal( test.context, undefined, "Empty jQuery Context" ); test = jQuery(document); - equals( test.selector, "", "Document Selector" ); - equals( test.context, document, "Document Context" ); + equal( test.selector, "", "Document Selector" ); + equal( test.context, document, "Document Context" ); test = jQuery(document.body); - equals( test.selector, "", "Body Selector" ); - equals( test.context, document.body, "Body Context" ); + equal( test.selector, "", "Body Selector" ); + equal( test.context, document.body, "Body Context" ); test = jQuery("#qunit-fixture"); - equals( test.selector, "#qunit-fixture", "#qunit-fixture Selector" ); - equals( test.context, document, "#qunit-fixture Context" ); + equal( test.selector, "#qunit-fixture", "#qunit-fixture Selector" ); + equal( test.context, document, "#qunit-fixture Context" ); test = jQuery("#notfoundnono"); - equals( test.selector, "#notfoundnono", "#notfoundnono Selector" ); - equals( test.context, document, "#notfoundnono Context" ); + equal( test.selector, "#notfoundnono", "#notfoundnono Selector" ); + equal( test.context, document, "#notfoundnono Context" ); test = jQuery("#qunit-fixture", document); - equals( test.selector, "#qunit-fixture", "#qunit-fixture Selector" ); - equals( test.context, document, "#qunit-fixture Context" ); + equal( test.selector, "#qunit-fixture", "#qunit-fixture Selector" ); + equal( test.context, document, "#qunit-fixture Context" ); test = jQuery("#qunit-fixture", document.body); - equals( test.selector, "#qunit-fixture", "#qunit-fixture Selector" ); - equals( test.context, document.body, "#qunit-fixture Context" ); + equal( test.selector, "#qunit-fixture", "#qunit-fixture Selector" ); + equal( test.context, document.body, "#qunit-fixture Context" ); // Test cloning test = jQuery(test); - equals( test.selector, "#qunit-fixture", "#qunit-fixture Selector" ); - equals( test.context, document.body, "#qunit-fixture Context" ); + equal( test.selector, "#qunit-fixture", "#qunit-fixture Selector" ); + equal( test.context, document.body, "#qunit-fixture Context" ); test = jQuery(document.body).find("#qunit-fixture"); - equals( test.selector, "#qunit-fixture", "#qunit-fixture find Selector" ); - equals( test.context, document.body, "#qunit-fixture find Context" ); + equal( test.selector, "#qunit-fixture", "#qunit-fixture find Selector" ); + equal( test.context, document.body, "#qunit-fixture find Context" ); test = jQuery("#qunit-fixture").filter("div"); - equals( test.selector, "#qunit-fixture.filter(div)", "#qunit-fixture filter Selector" ); - equals( test.context, document, "#qunit-fixture filter Context" ); + equal( test.selector, "#qunit-fixture.filter(div)", "#qunit-fixture filter Selector" ); + equal( test.context, document, "#qunit-fixture filter Context" ); test = jQuery("#qunit-fixture").not("div"); - equals( test.selector, "#qunit-fixture.not(div)", "#qunit-fixture not Selector" ); - equals( test.context, document, "#qunit-fixture not Context" ); + equal( test.selector, "#qunit-fixture.not(div)", "#qunit-fixture not Selector" ); + equal( test.context, document, "#qunit-fixture not Context" ); test = jQuery("#qunit-fixture").filter("div").not("div"); - equals( test.selector, "#qunit-fixture.filter(div).not(div)", "#qunit-fixture filter, not Selector" ); - equals( test.context, document, "#qunit-fixture filter, not Context" ); + equal( test.selector, "#qunit-fixture.filter(div).not(div)", "#qunit-fixture filter, not Selector" ); + equal( test.context, document, "#qunit-fixture filter, not Context" ); test = jQuery("#qunit-fixture").filter("div").not("div").end(); - equals( test.selector, "#qunit-fixture.filter(div)", "#qunit-fixture filter, not, end Selector" ); - equals( test.context, document, "#qunit-fixture filter, not, end Context" ); + equal( test.selector, "#qunit-fixture.filter(div)", "#qunit-fixture filter, not, end Selector" ); + equal( test.context, document, "#qunit-fixture filter, not, end Context" ); test = jQuery("#qunit-fixture").parent("body"); - equals( test.selector, "#qunit-fixture.parent(body)", "#qunit-fixture parent Selector" ); - equals( test.context, document, "#qunit-fixture parent Context" ); + equal( test.selector, "#qunit-fixture.parent(body)", "#qunit-fixture parent Selector" ); + equal( test.context, document, "#qunit-fixture parent Context" ); test = jQuery("#qunit-fixture").eq(0); - equals( test.selector, "#qunit-fixture.slice(0,1)", "#qunit-fixture eq Selector" ); - equals( test.context, document, "#qunit-fixture eq Context" ); + equal( test.selector, "#qunit-fixture.slice(0,1)", "#qunit-fixture eq Selector" ); + equal( test.context, document, "#qunit-fixture eq Context" ); var d = "
"; - equals( + equal( jQuery(d).appendTo(jQuery(d)).selector, jQuery(d).appendTo(d).selector, "manipulation methods make same selector for jQuery objects" @@ -215,8 +215,8 @@ test("browser", function() { var parts = this.split("\t"); if ( parts[2] ) { var ua = jQuery.uaMatch( parts[2] ); - equals( ua.browser, parts[0], "Checking browser for " + parts[2] ); - equals( ua.version, parts[1], "Checking version string for " + parts[2] ); + equal( ua.browser, parts[0], "Checking browser for " + parts[2] ); + equal( ua.version, parts[1], "Checking version string for " + parts[2] ); } }); @@ -228,7 +228,7 @@ test("browser", function() { test("amdModule", function() { expect(1); - equals( jQuery, amdDefined, "Make sure defined module matches jQuery" ); + equal( jQuery, amdDefined, "Make sure defined module matches jQuery" ); }); test("noConflict", function() { @@ -236,15 +236,15 @@ test("noConflict", function() { var $$ = jQuery; - equals( jQuery, jQuery.noConflict(), "noConflict returned the jQuery object" ); - equals( jQuery, $$, "Make sure jQuery wasn't touched." ); - equals( $, original$, "Make sure $ was reverted." ); + equal( jQuery, jQuery.noConflict(), "noConflict returned the jQuery object" ); + equal( jQuery, $$, "Make sure jQuery wasn't touched." ); + equal( $, original$, "Make sure $ was reverted." ); jQuery = $ = $$; - equals( jQuery.noConflict(true), $$, "noConflict returned the jQuery object" ); - equals( jQuery, originaljQuery, "Make sure jQuery was reverted." ); - equals( $, original$, "Make sure $ was reverted." ); + equal( jQuery.noConflict(true), $$, "noConflict returned the jQuery object" ); + equal( jQuery, originaljQuery, "Make sure jQuery was reverted." ); + equal( $, original$, "Make sure $ was reverted." ); ok( $$("#qunit-fixture").html("test"), "Make sure that jQuery still works." ); jQuery = $$; @@ -255,44 +255,44 @@ test("trim", function() { var nbsp = String.fromCharCode(160); - equals( jQuery.trim("hello "), "hello", "trailing space" ); - equals( jQuery.trim(" hello"), "hello", "leading space" ); - equals( jQuery.trim(" hello "), "hello", "space on both sides" ); - equals( jQuery.trim(" " + nbsp + "hello " + nbsp + " "), "hello", " " ); + equal( jQuery.trim("hello "), "hello", "trailing space" ); + equal( jQuery.trim(" hello"), "hello", "leading space" ); + equal( jQuery.trim(" hello "), "hello", "space on both sides" ); + equal( jQuery.trim(" " + nbsp + "hello " + nbsp + " "), "hello", " " ); - equals( jQuery.trim(), "", "Nothing in." ); - equals( jQuery.trim( undefined ), "", "Undefined" ); - equals( jQuery.trim( null ), "", "Null" ); - equals( jQuery.trim( 5 ), "5", "Number" ); - equals( jQuery.trim( false ), "false", "Boolean" ); + equal( jQuery.trim(), "", "Nothing in." ); + equal( jQuery.trim( undefined ), "", "Undefined" ); + equal( jQuery.trim( null ), "", "Null" ); + equal( jQuery.trim( 5 ), "5", "Number" ); + equal( jQuery.trim( false ), "false", "Boolean" ); }); test("type", function() { expect(23); - equals( jQuery.type(null), "null", "null" ); - equals( jQuery.type(undefined), "undefined", "undefined" ); - equals( jQuery.type(true), "boolean", "Boolean" ); - equals( jQuery.type(false), "boolean", "Boolean" ); - equals( jQuery.type(Boolean(true)), "boolean", "Boolean" ); - equals( jQuery.type(0), "number", "Number" ); - equals( jQuery.type(1), "number", "Number" ); - equals( jQuery.type(Number(1)), "number", "Number" ); - equals( jQuery.type(""), "string", "String" ); - equals( jQuery.type("a"), "string", "String" ); - equals( jQuery.type(String("a")), "string", "String" ); - equals( jQuery.type({}), "object", "Object" ); - equals( jQuery.type(/foo/), "regexp", "RegExp" ); - equals( jQuery.type(new RegExp("asdf")), "regexp", "RegExp" ); - equals( jQuery.type([1]), "array", "Array" ); - equals( jQuery.type(new Date()), "date", "Date" ); - equals( jQuery.type(new Function("return;")), "function", "Function" ); - equals( jQuery.type(function(){}), "function", "Function" ); - equals( jQuery.type(window), "object", "Window" ); - equals( jQuery.type(document), "object", "Document" ); - equals( jQuery.type(document.body), "object", "Element" ); - equals( jQuery.type(document.createTextNode("foo")), "object", "TextNode" ); - equals( jQuery.type(document.getElementsByTagName("*")), "object", "NodeList" ); + equal( jQuery.type(null), "null", "null" ); + equal( jQuery.type(undefined), "undefined", "undefined" ); + equal( jQuery.type(true), "boolean", "Boolean" ); + equal( jQuery.type(false), "boolean", "Boolean" ); + equal( jQuery.type(Boolean(true)), "boolean", "Boolean" ); + equal( jQuery.type(0), "number", "Number" ); + equal( jQuery.type(1), "number", "Number" ); + equal( jQuery.type(Number(1)), "number", "Number" ); + equal( jQuery.type(""), "string", "String" ); + equal( jQuery.type("a"), "string", "String" ); + equal( jQuery.type(String("a")), "string", "String" ); + equal( jQuery.type({}), "object", "Object" ); + equal( jQuery.type(/foo/), "regexp", "RegExp" ); + equal( jQuery.type(new RegExp("asdf")), "regexp", "RegExp" ); + equal( jQuery.type([1]), "array", "Array" ); + equal( jQuery.type(new Date()), "date", "Date" ); + equal( jQuery.type(new Function("return;")), "function", "Function" ); + equal( jQuery.type(function(){}), "function", "Function" ); + equal( jQuery.type(window), "object", "Window" ); + equal( jQuery.type(document), "object", "Document" ); + equal( jQuery.type(document.body), "object", "Element" ); + equal( jQuery.type(document.createTextNode("foo")), "object", "TextNode" ); + equal( jQuery.type(document.getElementsByTagName("*")), "object", "NodeList" ); }); test("isPlainObject", function() { @@ -475,23 +475,23 @@ test( "isNumeric", function() { ok( t(3.1415), "Positive floating point number"); ok( t(8e5), "Exponential notation"); ok( t("123e-2"), "Exponential notation string"); - equals( t(""), false, "Empty string"); - equals( t(" "), false, "Whitespace characters string"); - equals( t("\t\t"), false, "Tab characters string"); - equals( t("abcdefghijklm1234567890"), false, "Alphanumeric character string"); - equals( t("xabcdefx"), false, "Non-numeric character string"); - equals( t(true), false, "Boolean true literal"); - equals( t(false), false, "Boolean false literal"); - equals( t("bcfed5.2"), false, "Number with preceding non-numeric characters"); - equals( t("7.2acdgs"), false, "Number with trailling non-numeric characters"); - equals( t(undefined), false, "Undefined value"); - equals( t(null), false, "Null value"); - equals( t(NaN), false, "NaN value"); - equals( t(Infinity), false, "Infinity primitive"); - equals( t(Number.POSITIVE_INFINITY), false, "Positive Infinity"); - equals( t(Number.NEGATIVE_INFINITY), false, "Negative Infinity"); - equals( t({}), false, "Empty object"); - equals( t(function(){} ), false, "Instance of a function"); + equal( t(""), false, "Empty string"); + equal( t(" "), false, "Whitespace characters string"); + equal( t("\t\t"), false, "Tab characters string"); + equal( t("abcdefghijklm1234567890"), false, "Alphanumeric character string"); + equal( t("xabcdefx"), false, "Non-numeric character string"); + equal( t(true), false, "Boolean true literal"); + equal( t(false), false, "Boolean false literal"); + equal( t("bcfed5.2"), false, "Number with preceding non-numeric characters"); + equal( t("7.2acdgs"), false, "Number with trailling non-numeric characters"); + equal( t(undefined), false, "Undefined value"); + equal( t(null), false, "Null value"); + equal( t(NaN), false, "NaN value"); + equal( t(Infinity), false, "Infinity primitive"); + equal( t(Number.POSITIVE_INFINITY), false, "Positive Infinity"); + equal( t(Number.NEGATIVE_INFINITY), false, "Negative Infinity"); + equal( t({}), false, "Empty object"); + equal( t(function(){} ), false, "Instance of a function"); }); test("isXMLDoc - HTML", function() { @@ -583,11 +583,11 @@ test("jQuery('html')", function() { // Test multi-line HTML var div = jQuery("
\r\nsome text\n

some p

\nmore text\r\n
")[0]; - equals( div.nodeName.toUpperCase(), "DIV", "Make sure we're getting a div." ); - equals( div.firstChild.nodeType, 3, "Text node." ); - equals( div.lastChild.nodeType, 3, "Text node." ); - equals( div.childNodes[1].nodeType, 1, "Paragraph." ); - equals( div.childNodes[1].firstChild.nodeType, 3, "Paragraph text." ); + equal( div.nodeName.toUpperCase(), "DIV", "Make sure we're getting a div." ); + equal( div.firstChild.nodeType, 3, "Text node." ); + equal( div.lastChild.nodeType, 3, "Text node." ); + equal( div.childNodes[1].nodeType, 1, "Paragraph." ); + equal( div.childNodes[1].firstChild.nodeType, 3, "Paragraph text." ); QUnit.reset(); ok( jQuery("")[0], "Creating a link" ); @@ -613,9 +613,9 @@ test("jQuery('html')", function() { } html.push(""); html = jQuery(html.join(""))[0]; - equals( html.nodeName.toUpperCase(), "UL"); - equals( html.firstChild.nodeName.toUpperCase(), "LI"); - equals( html.childNodes.length, 50000 ); + equal( html.nodeName.toUpperCase(), "UL"); + equal( html.firstChild.nodeName.toUpperCase(), "LI"); + equal( html.childNodes.length, 50000 ); }); test("jQuery('html', context)", function() { @@ -623,7 +623,7 @@ test("jQuery('html', context)", function() { var $div = jQuery("
")[0]; var $span = jQuery("", $div); - equals($span.length, 1, "Verify a span created with a div context works, #1763"); + equal($span.length, 1, "Verify a span created with a div context works, #1763"); }); if ( !isLocal ) { @@ -633,9 +633,9 @@ test("jQuery(selector, xml).text(str) - Loaded via XML document", function() { jQuery.get("data/dashboard.xml", function(xml) { // tests for #1419 where IE was a problem var tab = jQuery("tab", xml).eq(0); - equals( tab.text(), "blabla", "Verify initial text correct" ); + equal( tab.text(), "blabla", "Verify initial text correct" ); tab.text("newtext"); - equals( tab.text(), "newtext", "Verify new text correct" ); + equal( tab.text(), "newtext", "Verify new text correct" ); start(); }); }); @@ -643,32 +643,32 @@ test("jQuery(selector, xml).text(str) - Loaded via XML document", function() { test("end()", function() { expect(3); - equals( "Yahoo", jQuery("#yahoo").parent().end().text(), "Check for end" ); + equal( "Yahoo", jQuery("#yahoo").parent().end().text(), "Check for end" ); ok( jQuery("#yahoo").end(), "Check for end with nothing to end" ); var x = jQuery("#yahoo"); x.parent(); - equals( "Yahoo", jQuery("#yahoo").text(), "Check for non-destructive behaviour" ); + equal( "Yahoo", jQuery("#yahoo").text(), "Check for non-destructive behaviour" ); }); test("length", function() { expect(1); - equals( jQuery("#qunit-fixture p").length, 6, "Get Number of Elements Found" ); + equal( jQuery("#qunit-fixture p").length, 6, "Get Number of Elements Found" ); }); test("size()", function() { expect(1); - equals( jQuery("#qunit-fixture p").size(), 6, "Get Number of Elements Found" ); + equal( jQuery("#qunit-fixture p").size(), 6, "Get Number of Elements Found" ); }); test("get()", function() { expect(1); - same( jQuery("#qunit-fixture p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" ); + deepEqual( jQuery("#qunit-fixture p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" ); }); test("toArray()", function() { expect(1); - same( jQuery("#qunit-fixture p").toArray(), + deepEqual( jQuery("#qunit-fixture p").toArray(), q("firstp","ap","sndp","en","sap","first"), "Convert jQuery object to an Array" ) }) @@ -711,13 +711,13 @@ test("inArray()", function() { test("get(Number)", function() { expect(2); - equals( jQuery("#qunit-fixture p").get(0), document.getElementById("firstp"), "Get A Single Element" ); + equal( jQuery("#qunit-fixture p").get(0), document.getElementById("firstp"), "Get A Single Element" ); strictEqual( jQuery("#firstp").get(1), undefined, "Try get with index larger elements count" ); }); test("get(-Number)",function() { expect(2); - equals( jQuery("p").get(-1), document.getElementById("first"), "Get a single element with negative index" ); + equal( jQuery("p").get(-1), document.getElementById("first"), "Get a single element with negative index" ); strictEqual( jQuery("#firstp").get(-2), undefined, "Try get with index negative index larger then elements count" ); }) @@ -737,14 +737,14 @@ test("slice()", function() { var $links = jQuery("#ap a"); - same( $links.slice(1,2).get(), q("groups"), "slice(1,2)" ); - same( $links.slice(1).get(), q("groups", "anchor1", "mark"), "slice(1)" ); - same( $links.slice(0,3).get(), q("google", "groups", "anchor1"), "slice(0,3)" ); - same( $links.slice(-1).get(), q("mark"), "slice(-1)" ); + deepEqual( $links.slice(1,2).get(), q("groups"), "slice(1,2)" ); + deepEqual( $links.slice(1).get(), q("groups", "anchor1", "mark"), "slice(1)" ); + deepEqual( $links.slice(0,3).get(), q("google", "groups", "anchor1"), "slice(0,3)" ); + deepEqual( $links.slice(-1).get(), q("mark"), "slice(-1)" ); - same( $links.eq(1).get(), q("groups"), "eq(1)" ); - same( $links.eq("2").get(), q("anchor1"), "eq('2')" ); - same( $links.eq(-1).get(), q("mark"), "eq(-1)" ); + deepEqual( $links.eq(1).get(), q("groups"), "eq(1)" ); + deepEqual( $links.eq("2").get(), q("anchor1"), "eq('2')" ); + deepEqual( $links.eq(-1).get(), q("mark"), "eq(-1)" ); }); test("first()/last()", function() { @@ -752,17 +752,17 @@ test("first()/last()", function() { var $links = jQuery("#ap a"), $none = jQuery("asdf"); - same( $links.first().get(), q("google"), "first()" ); - same( $links.last().get(), q("mark"), "last()" ); + deepEqual( $links.first().get(), q("google"), "first()" ); + deepEqual( $links.last().get(), q("mark"), "last()" ); - same( $none.first().get(), [], "first() none" ); - same( $none.last().get(), [], "last() none" ); + deepEqual( $none.first().get(), [], "first() none" ); + deepEqual( $none.last().get(), [], "last() none" ); }); test("map()", function() { expect(8); - same( + deepEqual( jQuery("#ap").map(function(){ return jQuery(this).find("a").get(); }).get(), @@ -770,7 +770,7 @@ test("map()", function() { "Array Map" ); - same( + deepEqual( jQuery("#ap > a").map(function(){ return this.parentNode; }).get(), @@ -782,35 +782,35 @@ test("map()", function() { var keys = jQuery.map( {a:1,b:2}, function( v, k ){ return k; }); - equals( keys.join(""), "ab", "Map the keys from a hash to an array" ); + equal( keys.join(""), "ab", "Map the keys from a hash to an array" ); var values = jQuery.map( {a:1,b:2}, function( v, k ){ return v; }); - equals( values.join(""), "12", "Map the values from a hash to an array" ); + equal( values.join(""), "12", "Map the values from a hash to an array" ); // object with length prop var values = jQuery.map( {a:1,b:2, length:3}, function( v, k ){ return v; }); - equals( values.join(""), "123", "Map the values from a hash with a length property to an array" ); + equal( values.join(""), "123", "Map the values from a hash with a length property to an array" ); var scripts = document.getElementsByTagName("script"); var mapped = jQuery.map( scripts, function( v, k ){ return v; }); - equals( mapped.length, scripts.length, "Map an array(-like) to a hash" ); + equal( mapped.length, scripts.length, "Map an array(-like) to a hash" ); var nonsense = document.getElementsByTagName("asdf"); var mapped = jQuery.map( nonsense, function( v, k ){ return v; }); - equals( mapped.length, nonsense.length, "Map an empty array(-like) to a hash" ); + equal( mapped.length, nonsense.length, "Map an empty array(-like) to a hash" ); var flat = jQuery.map( Array(4), function( v, k ){ return k % 2 ? k : [k,k,k];//try mixing array and regular returns }); - equals( flat.join(""), "00012223", "try the new flatten technique(#2616)" ); + equal( flat.join(""), "00012223", "try the new flatten technique(#2616)" ); }); test("jQuery.merge()", function() { @@ -818,20 +818,20 @@ test("jQuery.merge()", function() { var parse = jQuery.merge; - same( parse([],[]), [], "Empty arrays" ); + deepEqual( parse([],[]), [], "Empty arrays" ); - same( parse([1],[2]), [1,2], "Basic" ); - same( parse([1,2],[3,4]), [1,2,3,4], "Basic" ); + deepEqual( parse([1],[2]), [1,2], "Basic" ); + deepEqual( parse([1,2],[3,4]), [1,2,3,4], "Basic" ); - same( parse([1,2],[]), [1,2], "Second empty" ); - same( parse([],[1,2]), [1,2], "First empty" ); + deepEqual( parse([1,2],[]), [1,2], "Second empty" ); + deepEqual( parse([],[1,2]), [1,2], "First empty" ); // Fixed at [5998], #3641 - same( parse([-2,-1], [0,1,2]), [-2,-1,0,1,2], "Second array including a zero (falsy)"); + deepEqual( parse([-2,-1], [0,1,2]), [-2,-1,0,1,2], "Second array including a zero (falsy)"); // After fixing #5527 - same( parse([], [null, undefined]), [null, undefined], "Second array including null and undefined values"); - same( parse({length:0}, [1,2]), {length:2, 0:1, 1:2}, "First array like"); + deepEqual( parse([], [null, undefined]), [null, undefined], "Second array including null and undefined values"); + deepEqual( parse({length:0}, [1,2]), {length:2, 0:1, 1:2}, "First array like"); }); test("jQuery.extend(Object, Object)", function() { @@ -850,17 +850,17 @@ test("jQuery.extend(Object, Object)", function() { nestedarray = { arr: arr }; jQuery.extend(settings, options); - same( settings, merged, "Check if extended: settings must be extended" ); - same( options, optionsCopy, "Check if not modified: options must not be modified" ); + deepEqual( settings, merged, "Check if extended: settings must be extended" ); + deepEqual( options, optionsCopy, "Check if not modified: options must not be modified" ); jQuery.extend(settings, null, options); - same( settings, merged, "Check if extended: settings must be extended" ); - same( options, optionsCopy, "Check if not modified: options must not be modified" ); + deepEqual( settings, merged, "Check if extended: settings must be extended" ); + deepEqual( options, optionsCopy, "Check if not modified: options must not be modified" ); jQuery.extend(true, deep1, deep2); - same( deep1.foo, deepmerged.foo, "Check if foo: settings must be extended" ); - same( deep2.foo, deep2copy.foo, "Check if not deep2: options must not be modified" ); - equals( deep1.foo2, document, "Make sure that a deep clone was not attempted on the document" ); + deepEqual( deep1.foo, deepmerged.foo, "Check if foo: settings must be extended" ); + deepEqual( deep2.foo, deep2copy.foo, "Check if not deep2: options must not be modified" ); + equal( deep1.foo2, document, "Make sure that a deep clone was not attempted on the document" ); ok( jQuery.extend(true, {}, nestedarray).arr !== arr, "Deep extend of object must clone child array" ); @@ -871,12 +871,12 @@ test("jQuery.extend(Object, Object)", function() { var empty = {}; var optionsWithLength = { foo: { length: -1 } }; jQuery.extend(true, empty, optionsWithLength); - same( empty.foo, optionsWithLength.foo, "The length property must copy correctly" ); + deepEqual( empty.foo, optionsWithLength.foo, "The length property must copy correctly" ); empty = {}; var optionsWithDate = { foo: { date: new Date } }; jQuery.extend(true, empty, optionsWithDate); - same( empty.foo, optionsWithDate.foo, "Dates copy correctly" ); + deepEqual( empty.foo, optionsWithDate.foo, "Dates copy correctly" ); var myKlass = function() {}; var customObject = new myKlass(); @@ -907,10 +907,10 @@ test("jQuery.extend(Object, Object)", function() { var target = {}; var recursive = { foo:target, bar:5 }; jQuery.extend(true, target, recursive); - same( target, { bar:5 }, "Check to make sure a recursive obj doesn't go never-ending loop by not copying it over" ); + deepEqual( target, { bar:5 }, "Check to make sure a recursive obj doesn't go never-ending loop by not copying it over" ); var ret = jQuery.extend(true, { foo: [] }, { foo: [0] } ); // 1907 - equals( ret.foo.length, 1, "Check to make sure a value with coersion 'false' copies over when necessary to fix #1907" ); + equal( ret.foo.length, 1, "Check to make sure a value with coersion 'false' copies over when necessary to fix #1907" ); var ret = jQuery.extend(true, { foo: "1,2,3" }, { foo: [1, 2, 3] } ); ok( typeof ret.foo != "string", "Check to make sure values equal with coersion (but not actually equal) overwrite correctly" ); @@ -920,11 +920,11 @@ test("jQuery.extend(Object, Object)", function() { var obj = { foo:null }; jQuery.extend(true, obj, { foo:"notnull" } ); - equals( obj.foo, "notnull", "Make sure a null value can be overwritten" ); + equal( obj.foo, "notnull", "Make sure a null value can be overwritten" ); function func() {} jQuery.extend(func, { key: "value" } ); - equals( func.key, "value", "Verify a function can be extended" ); + equal( func.key, "value", "Verify a function can be extended" ); var defaults = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" }, defaultsCopy = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" }, @@ -935,118 +935,118 @@ test("jQuery.extend(Object, Object)", function() { merged2 = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "xx", xxx: "newstringx" }; var settings = jQuery.extend({}, defaults, options1, options2); - same( settings, merged2, "Check if extended: settings must be extended" ); - same( defaults, defaultsCopy, "Check if not modified: options1 must not be modified" ); - same( options1, options1Copy, "Check if not modified: options1 must not be modified" ); - same( options2, options2Copy, "Check if not modified: options2 must not be modified" ); + deepEqual( settings, merged2, "Check if extended: settings must be extended" ); + deepEqual( defaults, defaultsCopy, "Check if not modified: options1 must not be modified" ); + deepEqual( options1, options1Copy, "Check if not modified: options1 must not be modified" ); + deepEqual( options2, options2Copy, "Check if not modified: options2 must not be modified" ); }); test("jQuery.each(Object,Function)", function() { expect(14); jQuery.each( [0,1,2], function(i, n){ - equals( i, n, "Check array iteration" ); + equal( i, n, "Check array iteration" ); }); jQuery.each( [5,6,7], function(i, n){ - equals( i, n - 5, "Check array iteration" ); + equal( i, n - 5, "Check array iteration" ); }); jQuery.each( { name: "name", lang: "lang" }, function(i, n){ - equals( i, n, "Check object iteration" ); + equal( i, n, "Check object iteration" ); }); var total = 0; jQuery.each([1,2,3], function(i,v){ total += v; }); - equals( total, 6, "Looping over an array" ); + equal( total, 6, "Looping over an array" ); total = 0; jQuery.each([1,2,3], function(i,v){ total += v; if ( i == 1 ) return false; }); - equals( total, 3, "Looping over an array, with break" ); + equal( total, 3, "Looping over an array, with break" ); total = 0; jQuery.each({"a":1,"b":2,"c":3}, function(i,v){ total += v; }); - equals( total, 6, "Looping over an object" ); + equal( total, 6, "Looping over an object" ); total = 0; jQuery.each({"a":3,"b":3,"c":3}, function(i,v){ total += v; return false; }); - equals( total, 3, "Looping over an object, with break" ); + equal( total, 3, "Looping over an object, with break" ); var f = function(){}; f.foo = "bar"; jQuery.each(f, function(i){ f[i] = "baz"; }); - equals( "baz", f.foo, "Loop over a function" ); + equal( "baz", f.foo, "Loop over a function" ); var stylesheet_count = 0; jQuery.each(document.styleSheets, function(i){ stylesheet_count++; }); - equals(stylesheet_count, 2, "should not throw an error in IE while looping over document.styleSheets and return proper amount"); + equal(stylesheet_count, 2, "should not throw an error in IE while looping over document.styleSheets and return proper amount"); }); test("jQuery.makeArray", function(){ expect(17); - equals( jQuery.makeArray(jQuery("html>*"))[0].nodeName.toUpperCase(), "HEAD", "Pass makeArray a jQuery object" ); + equal( jQuery.makeArray(jQuery("html>*"))[0].nodeName.toUpperCase(), "HEAD", "Pass makeArray a jQuery object" ); - equals( jQuery.makeArray(document.getElementsByName("PWD")).slice(0,1)[0].name, "PWD", "Pass makeArray a nodelist" ); + equal( jQuery.makeArray(document.getElementsByName("PWD")).slice(0,1)[0].name, "PWD", "Pass makeArray a nodelist" ); - equals( (function(){ return jQuery.makeArray(arguments); })(1,2).join(""), "12", "Pass makeArray an arguments array" ); + equal( (function(){ return jQuery.makeArray(arguments); })(1,2).join(""), "12", "Pass makeArray an arguments array" ); - equals( jQuery.makeArray([1,2,3]).join(""), "123", "Pass makeArray a real array" ); + equal( jQuery.makeArray([1,2,3]).join(""), "123", "Pass makeArray a real array" ); - equals( jQuery.makeArray().length, 0, "Pass nothing to makeArray and expect an empty array" ); + equal( jQuery.makeArray().length, 0, "Pass nothing to makeArray and expect an empty array" ); - equals( jQuery.makeArray( 0 )[0], 0 , "Pass makeArray a number" ); + equal( jQuery.makeArray( 0 )[0], 0 , "Pass makeArray a number" ); - equals( jQuery.makeArray( "foo" )[0], "foo", "Pass makeArray a string" ); + equal( jQuery.makeArray( "foo" )[0], "foo", "Pass makeArray a string" ); - equals( jQuery.makeArray( true )[0].constructor, Boolean, "Pass makeArray a boolean" ); + equal( jQuery.makeArray( true )[0].constructor, Boolean, "Pass makeArray a boolean" ); - equals( jQuery.makeArray( document.createElement("div") )[0].nodeName.toUpperCase(), "DIV", "Pass makeArray a single node" ); + equal( jQuery.makeArray( document.createElement("div") )[0].nodeName.toUpperCase(), "DIV", "Pass makeArray a single node" ); - equals( jQuery.makeArray( {length:2, 0:"a", 1:"b"} ).join(""), "ab", "Pass makeArray an array like map (with length)" ); + equal( jQuery.makeArray( {length:2, 0:"a", 1:"b"} ).join(""), "ab", "Pass makeArray an array like map (with length)" ); ok( !!jQuery.makeArray( document.documentElement.childNodes ).slice(0,1)[0].nodeName, "Pass makeArray a childNodes array" ); // function, is tricky as it has length - equals( jQuery.makeArray( function(){ return 1;} )[0](), 1, "Pass makeArray a function" ); + equal( jQuery.makeArray( function(){ return 1;} )[0](), 1, "Pass makeArray a function" ); //window, also has length - equals( jQuery.makeArray(window)[0], window, "Pass makeArray the window" ); + equal( jQuery.makeArray(window)[0], window, "Pass makeArray the window" ); - equals( jQuery.makeArray(/a/)[0].constructor, RegExp, "Pass makeArray a regex" ); + equal( jQuery.makeArray(/a/)[0].constructor, RegExp, "Pass makeArray a regex" ); ok( jQuery.makeArray(document.getElementById("form")).length >= 13, "Pass makeArray a form (treat as elements)" ); // For #5610 - same( jQuery.makeArray({length: "0"}), [], "Make sure object is coerced properly."); - same( jQuery.makeArray({length: "5"}), [], "Make sure object is coerced properly."); + deepEqual( jQuery.makeArray({length: "0"}), [], "Make sure object is coerced properly."); + deepEqual( jQuery.makeArray({length: "5"}), [], "Make sure object is coerced properly."); }); test("jQuery.inArray", function(){ expect(3); - equals( jQuery.inArray( 0, false ), -1 , "Search in 'false' as array returns -1 and doesn't throw exception" ); + equal( jQuery.inArray( 0, false ), -1 , "Search in 'false' as array returns -1 and doesn't throw exception" ); - equals( jQuery.inArray( 0, null ), -1 , "Search in 'null' as array returns -1 and doesn't throw exception" ); + equal( jQuery.inArray( 0, null ), -1 , "Search in 'null' as array returns -1 and doesn't throw exception" ); - equals( jQuery.inArray( 0, undefined ), -1 , "Search in 'undefined' as array returns -1 and doesn't throw exception" ); + equal( jQuery.inArray( 0, undefined ), -1 , "Search in 'undefined' as array returns -1 and doesn't throw exception" ); }); test("jQuery.isEmptyObject", function(){ expect(2); - equals(true, jQuery.isEmptyObject({}), "isEmptyObject on empty object literal" ); - equals(false, jQuery.isEmptyObject({a:1}), "isEmptyObject on non-empty object literal" ); + equal(true, jQuery.isEmptyObject({}), "isEmptyObject on empty object literal" ); + equal(false, jQuery.isEmptyObject({a:1}), "isEmptyObject on non-empty object literal" ); // What about this ? - // equals(true, jQuery.isEmptyObject(null), "isEmptyObject on null" ); + // equal(true, jQuery.isEmptyObject(null), "isEmptyObject on null" ); }); test("jQuery.proxy", function(){ expect(7); - var test = function(){ equals( this, thisObject, "Make sure that scope is set properly." ); }; + var test = function(){ equal( this, thisObject, "Make sure that scope is set properly." ); }; var thisObject = { foo: "bar", method: test }; // Make sure normal works @@ -1059,32 +1059,32 @@ test("jQuery.proxy", function(){ jQuery.proxy( thisObject, "method" )(); // Make sure it doesn't freak out - equals( jQuery.proxy( null, thisObject ), undefined, "Make sure no function was returned." ); + equal( jQuery.proxy( null, thisObject ), undefined, "Make sure no function was returned." ); // Partial application - var test2 = function( a ){ equals( a, "pre-applied", "Ensure arguments can be pre-applied." ); }; + var test2 = function( a ){ equal( a, "pre-applied", "Ensure arguments can be pre-applied." ); }; jQuery.proxy( test2, null, "pre-applied" )(); // Partial application w/ normal arguments - var test3 = function( a, b ){ equals( b, "normal", "Ensure arguments can be pre-applied and passed as usual." ); }; + var test3 = function( a, b ){ equal( b, "normal", "Ensure arguments can be pre-applied and passed as usual." ); }; jQuery.proxy( test3, null, "pre-applied" )( "normal" ); // Test old syntax - var test4 = { meth: function( a ){ equals( a, "boom", "Ensure old syntax works." ); } }; + var test4 = { meth: function( a ){ equal( a, "boom", "Ensure old syntax works." ); } }; jQuery.proxy( test4, "meth" )( "boom" ); }); test("jQuery.parseJSON", function(){ expect(8); - equals( jQuery.parseJSON(), null, "Nothing in, null out." ); - equals( jQuery.parseJSON( null ), null, "Nothing in, null out." ); - equals( jQuery.parseJSON( "" ), null, "Nothing in, null out." ); + equal( jQuery.parseJSON(), null, "Nothing in, null out." ); + equal( jQuery.parseJSON( null ), null, "Nothing in, null out." ); + equal( jQuery.parseJSON( "" ), null, "Nothing in, null out." ); - same( jQuery.parseJSON("{}"), {}, "Plain object parsing." ); - same( jQuery.parseJSON("{\"test\":1}"), {"test":1}, "Plain object parsing." ); + deepEqual( jQuery.parseJSON("{}"), {}, "Plain object parsing." ); + deepEqual( jQuery.parseJSON("{\"test\":1}"), {"test":1}, "Plain object parsing." ); - same( jQuery.parseJSON("\n{\"test\":1}"), {"test":1}, "Make sure leading whitespaces are handled." ); + deepEqual( jQuery.parseJSON("\n{\"test\":1}"), {"test":1}, "Make sure leading whitespaces are handled." ); try { jQuery.parseJSON("{a:1}"); @@ -1139,7 +1139,7 @@ test("jQuery.sub() - Static Methods", function(){ //Test Simple Subclass ok(Subclass.topLevelMethod() === false, "Subclass.topLevelMethod thought debug was true"); ok(Subclass.config.locale == "en_US", Subclass.config.locale + " is wrong!"); - same(Subclass.config.test, undefined, "Subclass.config.test is set incorrectly"); + deepEqual(Subclass.config.test, undefined, "Subclass.config.test is set incorrectly"); equal(jQuery.ajax, Subclass.ajax, "The subclass failed to get all top level methods"); //Create a SubSubclass @@ -1148,7 +1148,7 @@ test("jQuery.sub() - Static Methods", function(){ //Make Sure the SubSubclass inherited properly ok(SubSubclass.topLevelMethod() === false, "SubSubclass.topLevelMethod thought debug was true"); ok(SubSubclass.config.locale == "en_US", SubSubclass.config.locale + " is wrong!"); - same(SubSubclass.config.test, undefined, "SubSubclass.config.test is set incorrectly"); + deepEqual(SubSubclass.config.test, undefined, "SubSubclass.config.test is set incorrectly"); equal(jQuery.ajax, SubSubclass.ajax, "The subsubclass failed to get all top level methods"); //Modify The Subclass and test the Modifications @@ -1157,7 +1157,7 @@ test("jQuery.sub() - Static Methods", function(){ SubSubclass.debug = true; SubSubclass.ajax = function() {return false;}; ok(SubSubclass.topLevelMethod(), "SubSubclass.topLevelMethod thought debug was false"); - same(SubSubclass(document).subClassMethod, Subclass.fn.subClassMethod, "Methods Differ!"); + deepEqual(SubSubclass(document).subClassMethod, Subclass.fn.subClassMethod, "Methods Differ!"); ok(SubSubclass.config.locale == "es_MX", SubSubclass.config.locale + " is wrong!"); ok(SubSubclass.config.test == "worked", "SubSubclass.config.test is set incorrectly"); notEqual(jQuery.ajax, SubSubclass.ajax, "The subsubclass failed to get all top level methods"); @@ -1165,8 +1165,8 @@ test("jQuery.sub() - Static Methods", function(){ //This shows that the modifications to the SubSubClass did not bubble back up to it's superclass ok(Subclass.topLevelMethod() === false, "Subclass.topLevelMethod thought debug was true"); ok(Subclass.config.locale == "en_US", Subclass.config.locale + " is wrong!"); - same(Subclass.config.test, undefined, "Subclass.config.test is set incorrectly"); - same(Subclass(document).subSubClassMethod, undefined, "subSubClassMethod set incorrectly"); + deepEqual(Subclass.config.test, undefined, "Subclass.config.test is set incorrectly"); + deepEqual(Subclass(document).subSubClassMethod, undefined, "subSubClassMethod set incorrectly"); equal(jQuery.ajax, Subclass.ajax, "The subclass failed to get all top level methods"); }); @@ -1211,27 +1211,27 @@ test("jQuery.sub() - .fn Methods", function(){ description = "(\""+selector+"\", "+context+")."+method+"("+(arg||"")+")"; - same( + deepEqual( jQuery(selector, context)[method](arg).subclassMethod, undefined, "jQuery"+description+" doesn't have Subclass methods" ); - same( + deepEqual( jQuery(selector, context)[method](arg).subclassSubclassMethod, undefined, "jQuery"+description+" doesn't have SubclassSubclass methods" ); - same( + deepEqual( Subclass(selector, context)[method](arg).subclassMethod, Subclass.fn.subclassMethod, "Subclass"+description+" has Subclass methods" ); - same( + deepEqual( Subclass(selector, context)[method](arg).subclassSubclassMethod, undefined, "Subclass"+description+" doesn't have SubclassSubclass methods" ); - same( + deepEqual( SubclassSubclass(selector, context)[method](arg).subclassMethod, Subclass.fn.subclassMethod, "SubclassSubclass"+description+" has Subclass methods" ); - same( + deepEqual( SubclassSubclass(selector, context)[method](arg).subclassSubclassMethod, SubclassSubclass.fn.subclassSubclassMethod, "SubclassSubclass"+description+" has SubclassSubclass methods" ); diff --git a/test/unit/css.js b/test/unit/css.js index ff1bb2641..e72b835ac 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -3,7 +3,7 @@ module("css", { teardown: moduleTeardown }); test("css(String|Hash)", function() { expect( 44 ); - equals( jQuery("#qunit-fixture").css("display"), "block", "Check for css property \"display\""); + equal( jQuery("#qunit-fixture").css("display"), "block", "Check for css property \"display\""); ok( jQuery("#nothiddendiv").is(":visible"), "Modifying CSS display: Assert element is visible"); jQuery("#nothiddendiv").css({display: "none"}); @@ -17,19 +17,19 @@ test("css(String|Hash)", function() { // These should be "auto" (or some better value) // temporarily provide "0px" for backwards compat - equals( div.css("width"), "0px", "Width on disconnected node." ); - equals( div.css("height"), "0px", "Height on disconnected node." ); + equal( div.css("width"), "0px", "Width on disconnected node." ); + equal( div.css("height"), "0px", "Height on disconnected node." ); div.css({ width: 4, height: 4 }); - equals( div.css("width"), "4px", "Width on disconnected node." ); - equals( div.css("height"), "4px", "Height on disconnected node." ); + equal( div.css("width"), "4px", "Width on disconnected node." ); + equal( div.css("height"), "4px", "Height on disconnected node." ); var div2 = jQuery( "
"); clone = element.clone(); - equals( clone[0].defaultValue, "foo", "Textarea defaultValue cloned correctly" ); + equal( clone[0].defaultValue, "foo", "Textarea defaultValue cloned correctly" ); }); test("clone(multiple selected options) (Bug #8129)", function() { expect(1); var element = jQuery(""); - equals( element.clone().find("option:selected").length, element.find("option:selected").length, "Multiple selected options cloned correctly" ); + equal( element.clone().find("option:selected").length, element.find("option:selected").length, "Multiple selected options cloned correctly" ); }); @@ -1164,8 +1164,8 @@ test("clone() on XML nodes", function() { var cloneTab = jQuery("tab", root).eq(0); origTab.text("origval"); cloneTab.text("cloneval"); - equals(origTab.text(), "origval", "Check original XML node was correctly set"); - equals(cloneTab.text(), "cloneval", "Check cloned XML node was correctly set"); + equal(origTab.text(), "origval", "Check original XML node was correctly set"); + equal(cloneTab.text(), "cloneval", "Check cloned XML node was correctly set"); start(); }); }); @@ -1186,17 +1186,17 @@ var testHtml = function(valueObj) { div = jQuery("
").html( valueObj("
") ); - equals( div.children().length, 2, "Make sure two child nodes exist." ); - equals( div.children().children().length, 1, "Make sure that a grandchild exists." ); + equal( div.children().length, 2, "Make sure two child nodes exist." ); + equal( div.children().children().length, 1, "Make sure that a grandchild exists." ); var space = jQuery("
").html(valueObj(" "))[0].innerHTML; ok( /^\xA0$|^ $/.test( space ), "Make sure entities are passed through correctly." ); - equals( jQuery("
").html(valueObj("&"))[0].innerHTML, "&", "Make sure entities are passed through correctly." ); + equal( jQuery("
").html(valueObj("&"))[0].innerHTML, "&", "Make sure entities are passed through correctly." ); jQuery("#qunit-fixture").html(valueObj("")); - equals( jQuery("#qunit-fixture").children().length, 1, "Make sure there is a child element." ); - equals( jQuery("#qunit-fixture").children()[0].nodeName.toUpperCase(), "STYLE", "And that a style element was inserted." ); + equal( jQuery("#qunit-fixture").children().length, 1, "Make sure there is a child element." ); + equal( jQuery("#qunit-fixture").children()[0].nodeName.toUpperCase(), "STYLE", "And that a style element was inserted." ); QUnit.reset(); // using contents will get comments regular, text, and comment nodes @@ -1205,25 +1205,25 @@ var testHtml = function(valueObj) { // this is needed, or the expando added by jQuery unique will yield a different html j.find("b").removeData(); - equals( j.html().replace(/ xmlns="[^"]+"/g, "").toLowerCase(), "bold", "Check node,textnode,comment with html()" ); + equal( j.html().replace(/ xmlns="[^"]+"/g, "").toLowerCase(), "bold", "Check node,textnode,comment with html()" ); jQuery("#qunit-fixture").html(valueObj("