Commit 7ff3da18 authored by Rick Waldron's avatar Rick Waldron

Unit tests are linted and passing.

parent 66501469
...@@ -79,7 +79,7 @@ module.exports = function( grunt ) { ...@@ -79,7 +79,7 @@ module.exports = function( grunt ) {
"dist/jquery.min.js": [ "<banner>", "dist/jquery.js" ] "dist/jquery.min.js": [ "<banner>", "dist/jquery.js" ]
}, },
lint: { lint: {
files: [ "grunt.js", "dist/jquery.js" ] files: [ "test/unit/**/*.js", "grunt.js", "dist/jquery.js" ]
}, },
qunit: { qunit: {
files: "test/index.html" files: "test/index.html"
...@@ -99,14 +99,12 @@ module.exports = function( grunt ) { ...@@ -99,14 +99,12 @@ module.exports = function( grunt ) {
trailing: true, trailing: true,
undef: true, undef: true,
smarttabs: true, smarttabs: true,
predef: [
"define",
"DOMParser",
"__dirname"
],
maxerr: 100 maxerr: 100
}, },
globals: { globals: {
define: true,
DOMParser: true,
__dirname: true,
jQuery: true, jQuery: true,
global: true, global: true,
module: true, module: true,
...@@ -114,7 +112,37 @@ module.exports = function( grunt ) { ...@@ -114,7 +112,37 @@ module.exports = function( grunt ) {
require: true, require: true,
file: true, file: true,
log: true, log: true,
console: true console: true,
QUnit: true,
ok: true,
equal: true,
test: true,
asyncTest: true,
notEqual: true,
deepEqual: true,
strictEqual: true,
notStrictEqual: true,
start: true,
stop: true,
expect: true,
raises: true,
testIframe: true,
testIframeWithCallback: true,
createDashboardXML: true,
moduleTeardown: true,
testFoo: true,
foobar: true,
url: true,
t: true,
q: true,
amdDefined: true,
fireNative: true,
hasPHP: true,
isLocal: true,
originaljQuery: true,
"$": true,
"original$": true
} }
}, },
uglify: {} uglify: {}
......
...@@ -381,7 +381,7 @@ test(".ajax() - headers" , function() { ...@@ -381,7 +381,7 @@ test(".ajax() - headers" , function() {
headers: requestHeaders, headers: requestHeaders,
success: function( data , _ , xhr ) { success: function( data , _ , xhr ) {
var tmp = []; var tmp = [], i;
for ( i in requestHeaders ) { for ( i in requestHeaders ) {
tmp.push( i , ": " , requestHeaders[ i ] , "\n" ); tmp.push( i , ": " , requestHeaders[ i ] , "\n" );
} }
...@@ -1000,7 +1000,7 @@ test("jQuery.param()", function() { ...@@ -1000,7 +1000,7 @@ test("jQuery.param()", function() {
jQuery.ajaxSetup({ traditional: true }); jQuery.ajaxSetup({ traditional: true });
var params = {foo:"bar", baz:42, quux:"All your base are belong to us"}; params = {foo:"bar", baz:42, quux:"All your base are belong to us"};
equal( 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" }; params = {someName: [1, 2, 3], regularThing: "blah" };
...@@ -1038,10 +1038,13 @@ test("jQuery.param() Constructed prop values", function() { ...@@ -1038,10 +1038,13 @@ test("jQuery.param() Constructed prop values", function() {
this.prop = "val"; this.prop = "val";
} }
var params = { "test": new String("foo") }; var MyString = String,
MyNumber = Number,
params = { "test": new MyString("foo") };
equal( jQuery.param( params, false ), "test=foo", "Do not mistake new String() for a plain object" ); equal( jQuery.param( params, false ), "test=foo", "Do not mistake new String() for a plain object" );
params = { "test": new Number(5) }; params = { "test": new MyNumber(5) };
equal( jQuery.param( params, false ), "test=5", "Do not mistake new Number() for a plain object" ); equal( jQuery.param( params, false ), "test=5", "Do not mistake new Number() for a plain object" );
params = { "test": new Date() }; params = { "test": new Date() };
...@@ -1054,14 +1057,20 @@ test("jQuery.param() Constructed prop values", function() { ...@@ -1054,14 +1057,20 @@ test("jQuery.param() Constructed prop values", function() {
test("synchronous request", function() { test("synchronous request", function() {
expect(1); expect(1);
ok( /^{ "data"/.test( jQuery.ajax({url: url("data/json_obj.js"), dataType: "text", async: false}).responseText ), "check returned text" ); var response = jQuery.ajax({
url: url("data/json_obj.js"),
dataType: "text",
async: false
}).responseText;
ok( /^\{ "data"/.test( response ), "check returned text" );
}); });
test("synchronous request with callbacks", function() { test("synchronous request with callbacks", function() {
expect(2); expect(2);
var result; var result;
jQuery.ajax({url: url("data/json_obj.js"), async: false, dataType: "text", success: function(data) { ok(true, "sucess callback executed"); result = data; } }); jQuery.ajax({url: url("data/json_obj.js"), async: false, dataType: "text", success: function(data) { ok(true, "sucess callback executed"); result = data; } });
ok( /^{ "data"/.test( result ), "check returned text" ); ok( /^\{ "data"/.test( result ), "check returned text" );
}); });
test("pass-through request object", function() { test("pass-through request object", function() {
...@@ -1113,8 +1122,9 @@ test("ajax cache", function () { ...@@ -1113,8 +1122,9 @@ test("ajax cache", function () {
} }
equal(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"); ok(oldOne != "tobereplaced555", "Test to be sure parameter (if it was there) was replaced");
if(++count == 6) if(++count == 6) {
start(); start();
}
}); });
ok( jQuery.ajax({url: "data/text.php", cache:false}), "test with no parameters" ); ok( jQuery.ajax({url: "data/text.php", cache:false}), "test with no parameters" );
...@@ -1372,7 +1382,11 @@ jQuery.each( [ "Same Domain", "Cross Domain" ] , function( crossDomain , label ) ...@@ -1372,7 +1382,11 @@ jQuery.each( [ "Same Domain", "Cross Domain" ] , function( crossDomain , label )
expect(24); expect(24);
var count = 0; var count = 0;
function plus(){ if ( ++count == 20 ) start(); } function plus(){
if ( ++count == 20 ) {
start();
}
}
stop(); stop();
...@@ -1858,19 +1872,19 @@ test("jQuery.getJSON(String, Function) - JSON object", function() { ...@@ -1858,19 +1872,19 @@ test("jQuery.getJSON(String, Function) - JSON object", function() {
}); });
}); });
test("jQuery.getJSON - Using Native JSON", function() { asyncTest("jQuery.getJSON - Using Native JSON", function() {
expect(2); expect(2);
var old = window.JSON; var old = window.JSON;
JSON = {
parse: function(str){ window.JSON = {
parse: function(str) {
ok( true, "Verifying that parse method was run" ); ok( true, "Verifying that parse method was run" );
return true; return true;
} }
}; };
stop(); jQuery.getJSON(url("data/json.php"), function( json ) {
jQuery.getJSON(url("data/json.php"), function(json) {
window.JSON = old; window.JSON = old;
equal( json, true, "Verifying return value" ); equal( json, true, "Verifying return value" );
start(); start();
...@@ -1930,7 +1944,9 @@ test("jQuery.post(String, Hash, Function) - simple with xml", function() { ...@@ -1930,7 +1944,9 @@ test("jQuery.post(String, Hash, Function) - simple with xml", function() {
equal( jQuery("calculation", this).text(), "5-2", "Check for XML" ); equal( jQuery("calculation", this).text(), "5-2", "Check for XML" );
equal( jQuery("result", this).text(), "3", "Check for XML" ); equal( jQuery("result", this).text(), "3", "Check for XML" );
}); });
if ( ++done === 2 ) start(); if ( ++done === 2 ) {
start();
}
}); });
jQuery.post(url("data/name.php?xml=5-2"), {}, function(xml){ jQuery.post(url("data/name.php?xml=5-2"), {}, function(xml){
...@@ -1938,7 +1954,9 @@ test("jQuery.post(String, Hash, Function) - simple with xml", function() { ...@@ -1938,7 +1954,9 @@ test("jQuery.post(String, Hash, Function) - simple with xml", function() {
equal( jQuery("calculation", this).text(), "5-2", "Check for XML" ); equal( jQuery("calculation", this).text(), "5-2", "Check for XML" );
equal( jQuery("result", this).text(), "3", "Check for XML" ); equal( jQuery("result", this).text(), "3", "Check for XML" );
}); });
if ( ++done === 2 ) start(); if ( ++done === 2 ) {
start();
}
}); });
}); });
...@@ -2196,14 +2214,22 @@ test("jQuery ajax - failing cross-domain", function() { ...@@ -2196,14 +2214,22 @@ test("jQuery ajax - failing cross-domain", function() {
url: "http://somewebsitethatdoesnotexist-67864863574657654.com", url: "http://somewebsitethatdoesnotexist-67864863574657654.com",
success: function(){ ok( false , "success" ); }, success: function(){ ok( false , "success" ); },
error: function(xhr,_,e){ ok( true , "file not found: " + xhr.status + " => " + e ); }, error: function(xhr,_,e){ ok( true , "file not found: " + xhr.status + " => " + e ); },
complete: function() { if ( ! --i ) start(); } complete: function() {
if ( ! --i ) {
start();
}
}
}); });
jQuery.ajax({ jQuery.ajax({
url: "http://www.google.com", url: "http://www.google.com",
success: function(){ ok( false , "success" ); }, success: function(){ ok( false , "success" ); },
error: function(xhr,_,e){ ok( true , "access denied: " + xhr.status + " => " + e ); }, error: function(xhr,_,e){ ok( true , "access denied: " + xhr.status + " => " + e ); },
complete: function() { if ( ! --i ) start(); } complete: function() {
if ( ! --i ) {
start();
}
}
}); });
}); });
...@@ -2498,7 +2524,7 @@ test( "jQuery.domManip - script in comments are properly evaluated (#11402)", fu ...@@ -2498,7 +2524,7 @@ test( "jQuery.domManip - script in comments are properly evaluated (#11402)", fu
}); });
test("jQuery.ajax - active counter", function() { test("jQuery.ajax - active counter", function() {
ok( jQuery.active == 0, "ajax active counter should be zero: " + jQuery.active ); ok( jQuery.active === 0, "ajax active counter should be zero: " + jQuery.active );
}); });
} }
...@@ -156,7 +156,9 @@ test("attr(Hash)", function() { ...@@ -156,7 +156,9 @@ test("attr(Hash)", function() {
expect(3); expect(3);
var pass = true; var pass = true;
jQuery("div").attr({foo: "baz", zoo: "ping"}).each(function(){ jQuery("div").attr({foo: "baz", zoo: "ping"}).each(function(){
if ( this.getAttribute("foo") != "baz" && this.getAttribute("zoo") != "ping" ) pass = false; if ( this.getAttribute("foo") != "baz" && this.getAttribute("zoo") != "ping" ) {
pass = false;
}
}); });
ok( pass, "Set Multiple Attributes" ); ok( pass, "Set Multiple Attributes" );
equal( jQuery("#text1").attr({value: function() { return this.id; }})[0].value, "text1", "Set attribute to computed value #1" ); equal( jQuery("#text1").attr({value: function() { return this.id; }})[0].value, "text1", "Set attribute to computed value #1" );
...@@ -354,9 +356,12 @@ test("attr(String, Object)", function() { ...@@ -354,9 +356,12 @@ test("attr(String, Object)", function() {
equal( $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) // Setting attributes on svg elements (bug #3116)
var $svg = jQuery("<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' baseProfile='full' width='200' height='200'>" var $svg = jQuery(
+ "<circle cx='200' cy='200' r='150' />" "<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' baseProfile='full' width='200' height='200'>" +
+ "</svg>").appendTo("body");
"<circle cx='200' cy='200' r='150' />" +
"</svg>"
).appendTo("body");
equal( $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(); $svg.remove();
...@@ -811,7 +816,7 @@ var testVal = function(valueObj) { ...@@ -811,7 +816,7 @@ var testVal = function(valueObj) {
j.val(valueObj( "asdf" )); j.val(valueObj( "asdf" ));
equal( j.val(), "asdf", "Check node,textnode,comment with val()" ); equal( j.val(), "asdf", "Check node,textnode,comment with val()" );
j.removeAttr("value"); j.removeAttr("value");
} };
test("val(String/Number)", function() { test("val(String/Number)", function() {
testVal(bareObj); testVal(bareObj);
...@@ -972,7 +977,9 @@ test("addClass(Function) with incoming value", function() { ...@@ -972,7 +977,9 @@ test("addClass(Function) with incoming value", function() {
var pass = true; var pass = true;
for ( var i = 0; i < div.length; i++ ) { for ( var i = 0; i < div.length; i++ ) {
if ( div.get(i).className.indexOf("test") == -1 ) pass = false; if ( div.get(i).className.indexOf("test") == -1 ) {
pass = false;
}
} }
ok( pass, "Add Class" ); ok( pass, "Add Class" );
}); });
...@@ -1180,7 +1187,8 @@ test("addClass, removeClass, hasClass", function() { ...@@ -1180,7 +1187,8 @@ test("addClass, removeClass, hasClass", function() {
ok( jq.hasClass("hi"), "Check has1" ); ok( jq.hasClass("hi"), "Check has1" );
ok( jq.hasClass("bar"), "Check has2" ); ok( jq.hasClass("bar"), "Check has2" );
var jq = jQuery("<p class='class1\nclass2\tcla.ss3\n\rclass4'></p>"); jq = jQuery("<p class='class1\nclass2\tcla.ss3\n\rclass4'></p>");
ok( jq.hasClass("class1"), "Check hasClass with line feed" ); ok( jq.hasClass("class1"), "Check hasClass with line feed" );
ok( jq.is(".class1"), "Check is with line feed" ); ok( jq.is(".class1"), "Check is with line feed" );
ok( jq.hasClass("class2"), "Check hasClass with tab" ); ok( jq.hasClass("class2"), "Check hasClass with tab" );
...@@ -1190,13 +1198,13 @@ test("addClass, removeClass, hasClass", function() { ...@@ -1190,13 +1198,13 @@ test("addClass, removeClass, hasClass", function() {
ok( jq.is(".class4"), "Check is with carriage return" ); ok( jq.is(".class4"), "Check is with carriage return" );
jq.removeClass("class2"); jq.removeClass("class2");
ok( jq.hasClass("class2")==false, "Check the class has been properly removed" ); ok( jq.hasClass("class2")===false, "Check the class has been properly removed" );
jq.removeClass("cla"); jq.removeClass("cla");
ok( jq.hasClass("cla.ss3"), "Check the dotted class has not been removed" ); ok( jq.hasClass("cla.ss3"), "Check the dotted class has not been removed" );
jq.removeClass("cla.ss3"); jq.removeClass("cla.ss3");
ok( jq.hasClass("cla.ss3")==false, "Check the dotted class has been removed" ); ok( jq.hasClass("cla.ss3")===false, "Check the dotted class has been removed" );
jq.removeClass("class4"); jq.removeClass("class4");
ok( jq.hasClass("class4")==false, "Check the class has been properly removed" ); ok( jq.hasClass("class4")===false, "Check the class has been properly removed" );
}); });
test("contents().hasClass() returns correct values", function() { test("contents().hasClass() returns correct values", function() {
......
...@@ -322,10 +322,10 @@ test("type", function() { ...@@ -322,10 +322,10 @@ test("type", function() {
equal( jQuery.type(document.getElementsByTagName("*")), "object", "NodeList" ); equal( jQuery.type(document.getElementsByTagName("*")), "object", "NodeList" );
}); });
test("isPlainObject", function() { asyncTest("isPlainObject", function() {
expect(15); expect(15);
stop(); var iframe;
// The use case that we want to match // The use case that we want to match
ok(jQuery.isPlainObject({}), "{}"); ok(jQuery.isPlainObject({}), "{}");
...@@ -341,7 +341,7 @@ test("isPlainObject", function() { ...@@ -341,7 +341,7 @@ test("isPlainObject", function() {
ok(!jQuery.isPlainObject([]), "array"); ok(!jQuery.isPlainObject([]), "array");
// Instantiated objects shouldn't be matched // Instantiated objects shouldn't be matched
ok(!jQuery.isPlainObject(new Date), "new Date"); ok(!jQuery.isPlainObject(new Date()), "new Date");
var fn = function(){}; var fn = function(){};
...@@ -349,14 +349,14 @@ test("isPlainObject", function() { ...@@ -349,14 +349,14 @@ test("isPlainObject", function() {
ok(!jQuery.isPlainObject(fn), "fn"); ok(!jQuery.isPlainObject(fn), "fn");
// Again, instantiated objects shouldn't be matched // Again, instantiated objects shouldn't be matched
ok(!jQuery.isPlainObject(new fn), "new fn (no methods)"); ok(!jQuery.isPlainObject(new fn()), "new fn (no methods)");
// Makes the function a little more realistic // Makes the function a little more realistic
// (and harder to detect, incidentally) // (and harder to detect, incidentally)
fn.prototype = {someMethod: function(){}}; fn.prototype = {someMethod: function(){}};
// Again, instantiated objects shouldn't be matched // Again, instantiated objects shouldn't be matched
ok(!jQuery.isPlainObject(new fn), "new fn"); ok(!jQuery.isPlainObject(new fn()), "new fn");
// DOM Element // DOM Element
ok(!jQuery.isPlainObject(document.createElement("div")), "DOM Element"); ok(!jQuery.isPlainObject(document.createElement("div")), "DOM Element");
...@@ -372,12 +372,12 @@ test("isPlainObject", function() { ...@@ -372,12 +372,12 @@ test("isPlainObject", function() {
} }
try { try {
var iframe = document.createElement("iframe"); iframe = document.createElement("iframe");
document.body.appendChild(iframe); document.body.appendChild(iframe);
window.iframeDone = function(otherObject){ window.iframeDone = function(otherObject){
// Objects from other windows should be matched // Objects from other windows should be matched
ok(jQuery.isPlainObject(new otherObject), "new otherObject"); ok(jQuery.isPlainObject(new otherObject()), "new otherObject");
document.body.removeChild( iframe ); document.body.removeChild( iframe );
start(); start();
}; };
...@@ -474,7 +474,7 @@ test("isFunction", function() { ...@@ -474,7 +474,7 @@ test("isFunction", function() {
ok( jQuery.isFunction(fn), "Recursive Function Call" ); ok( jQuery.isFunction(fn), "Recursive Function Call" );
fn({ some: "data" }); fn({ some: "data" });
}; }
callme(function(){ callme(function(){
callme(function(){}); callme(function(){});
...@@ -482,7 +482,7 @@ test("isFunction", function() { ...@@ -482,7 +482,7 @@ test("isFunction", function() {
}); });
test( "isNumeric", function() { test( "isNumeric", function() {
expect( 37 ); expect( 36 );
var t = jQuery.isNumeric, var t = jQuery.isNumeric,
Traditionalists = function(n) { Traditionalists = function(n) {
...@@ -501,7 +501,9 @@ test( "isNumeric", function() { ...@@ -501,7 +501,9 @@ test( "isNumeric", function() {
ok( t(0), "Zero integer number"); ok( t(0), "Zero integer number");
ok( t(32), "Positive integer number"); ok( t(32), "Positive integer number");
ok( t("040"), "Octal integer literal string"); ok( t("040"), "Octal integer literal string");
ok( t(0144), "Octal integer literal"); // OctalIntegerLiteral has been deprecated since ES3/1999
// It doesn't pass lint, so disabling until a solution can be found
//ok( t(0144), "Octal integer literal");
ok( t("0xFF"), "Hexadecimal integer literal string"); ok( t("0xFF"), "Hexadecimal integer literal string");
ok( t(0xFFF), "Hexadecimal integer literal"); ok( t(0xFFF), "Hexadecimal integer literal");
ok( t("-1.6"), "Negative floating point string"); ok( t("-1.6"), "Negative floating point string");
...@@ -529,7 +531,7 @@ test( "isNumeric", function() { ...@@ -529,7 +531,7 @@ test( "isNumeric", function() {
equal( t(rong), false, "Custom .toString returning non-number"); equal( t(rong), false, "Custom .toString returning non-number");
equal( t({}), false, "Empty object"); equal( t({}), false, "Empty object");
equal( t(function(){} ), false, "Instance of a function"); equal( t(function(){} ), false, "Instance of a function");
equal( t( new Date ), false, "Instance of a Date"); equal( t( new Date() ), false, "Instance of a Date");
equal( t(function(){} ), false, "Instance of a function"); equal( t(function(){} ), false, "Instance of a function");
}); });
...@@ -705,8 +707,8 @@ test("toArray()", function() { ...@@ -705,8 +707,8 @@ test("toArray()", function() {
expect(1); expect(1);
deepEqual( jQuery("#qunit-fixture p").toArray(), deepEqual( jQuery("#qunit-fixture p").toArray(),
q("firstp","ap","sndp","en","sap","first"), q("firstp","ap","sndp","en","sap","first"),
"Convert jQuery object to an Array" ) "Convert jQuery object to an Array" );
}) });
test("inArray()", function() { test("inArray()", function() {
expect(19); expect(19);
...@@ -754,7 +756,7 @@ test("get(-Number)",function() { ...@@ -754,7 +756,7 @@ test("get(-Number)",function() {
expect(2); expect(2);
equal( 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" ); strictEqual( jQuery("#firstp").get(-2), undefined, "Try get with index negative index larger then elements count" );
}) });
test("each(Function)", function() { test("each(Function)", function() {
expect(1); expect(1);
...@@ -762,7 +764,9 @@ test("each(Function)", function() { ...@@ -762,7 +764,9 @@ test("each(Function)", function() {
div.each(function(){this.foo = "zoo";}); div.each(function(){this.foo = "zoo";});
var pass = true; var pass = true;
for ( var i = 0; i < div.size(); i++ ) { for ( var i = 0; i < div.size(); i++ ) {
if ( div.get(i).foo != "zoo" ) pass = false; if ( div.get(i).foo != "zoo" ) {
pass = false;
}
} }
ok( pass, "Execute a function, Relative" ); ok( pass, "Execute a function, Relative" );
}); });
...@@ -813,36 +817,37 @@ test("map()", function() { ...@@ -813,36 +817,37 @@ test("map()", function() {
"Single Map" "Single Map"
); );
var keys, values, scripts, nonsense, mapped, flat;
//for #2616 //for #2616
var keys = jQuery.map( {a:1,b:2}, function( v, k ){ keys = jQuery.map( {a:1,b:2}, function( v, k ){
return k; return k;
}); });
equal( 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 ){ values = jQuery.map( {a:1,b:2}, function( v, k ){
return v; return v;
}); });
equal( 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 // object with length prop
var values = jQuery.map( {a:1,b:2, length:3}, function( v, k ){ values = jQuery.map( {a:1,b:2, length:3}, function( v, k ){
return v; return v;
}); });
equal( 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"); scripts = document.getElementsByTagName("script");
var mapped = jQuery.map( scripts, function( v, k ){ mapped = jQuery.map( scripts, function( v, k ){
return v; return v;
}); });
equal( 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"); nonsense = document.getElementsByTagName("asdf");
var mapped = jQuery.map( nonsense, function( v, k ){ mapped = jQuery.map( nonsense, function( v, k ){
return v; return v;
}); });
equal( 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 ){ flat = jQuery.map( Array(4), function( v, k ){
return k % 2 ? k : [k,k,k];//try mixing array and regular returns return k % 2 ? k : [k,k,k];//try mixing array and regular returns
}); });
equal( flat.join(""), "00012223", "try the new flatten technique(#2616)" ); equal( flat.join(""), "00012223", "try the new flatten technique(#2616)" );
...@@ -909,7 +914,7 @@ test("jQuery.extend(Object, Object)", function() { ...@@ -909,7 +914,7 @@ test("jQuery.extend(Object, Object)", function() {
deepEqual( empty.foo, optionsWithLength.foo, "The length property must copy correctly" ); deepEqual( empty.foo, optionsWithLength.foo, "The length property must copy correctly" );
empty = {}; empty = {};
var optionsWithDate = { foo: { date: new Date } }; var optionsWithDate = { foo: { date: new Date() } };
jQuery.extend(true, empty, optionsWithDate); jQuery.extend(true, empty, optionsWithDate);
deepEqual( empty.foo, optionsWithDate.foo, "Dates copy correctly" ); deepEqual( empty.foo, optionsWithDate.foo, "Dates copy correctly" );
...@@ -926,7 +931,8 @@ test("jQuery.extend(Object, Object)", function() { ...@@ -926,7 +931,8 @@ test("jQuery.extend(Object, Object)", function() {
jQuery.extend(true, empty, optionsWithCustomObject); jQuery.extend(true, empty, optionsWithCustomObject);
ok( empty.foo && empty.foo.date === customObject, "Custom objects copy correctly" ); ok( empty.foo && empty.foo.date === customObject, "Custom objects copy correctly" );
var ret = jQuery.extend(true, { foo: 4 }, { foo: new Number(5) } ); var MyNumber = Number;
var ret = jQuery.extend(true, { foo: 4 }, { foo: new MyNumber(5) } );
ok( ret.foo == 5, "Wrapped numbers copy correctly" ); ok( ret.foo == 5, "Wrapped numbers copy correctly" );
var nullUndef; var nullUndef;
...@@ -944,13 +950,13 @@ test("jQuery.extend(Object, Object)", function() { ...@@ -944,13 +950,13 @@ test("jQuery.extend(Object, Object)", function() {
jQuery.extend(true, target, recursive); jQuery.extend(true, target, recursive);
deepEqual( 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 ret = jQuery.extend(true, { foo: [] }, { foo: [0] } ); // 1907
equal( 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] } ); 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" ); ok( typeof ret.foo != "string", "Check to make sure values equal with coersion (but not actually equal) overwrite correctly" );
var ret = jQuery.extend(true, { foo:"bar" }, { foo:null } ); ret = jQuery.extend(true, { foo:"bar" }, { foo:null } );
ok( typeof ret.foo !== "undefined", "Make sure a null value doesn't crash with deep extend, for #1908" ); ok( typeof ret.foo !== "undefined", "Make sure a null value doesn't crash with deep extend, for #1908" );
var obj = { foo:null }; var obj = { foo:null };
...@@ -969,7 +975,7 @@ test("jQuery.extend(Object, Object)", function() { ...@@ -969,7 +975,7 @@ test("jQuery.extend(Object, Object)", function() {
options2Copy = { xstring2: "xx", xxx: "newstringx" }, options2Copy = { xstring2: "xx", xxx: "newstringx" },
merged2 = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "xx", xxx: "newstringx" }; merged2 = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "xx", xxx: "newstringx" };
var settings = jQuery.extend({}, defaults, options1, options2); settings = jQuery.extend({}, defaults, options1, options2);
deepEqual( settings, merged2, "Check if extended: settings must be extended" ); deepEqual( settings, merged2, "Check if extended: settings must be extended" );
deepEqual( defaults, defaultsCopy, "Check if not modified: options1 must not be modified" ); 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( options1, options1Copy, "Check if not modified: options1 must not be modified" );
...@@ -994,7 +1000,12 @@ test("jQuery.each(Object,Function)", function() { ...@@ -994,7 +1000,12 @@ test("jQuery.each(Object,Function)", function() {
jQuery.each([1,2,3], function(i,v){ total += v; }); jQuery.each([1,2,3], function(i,v){ total += v; });
equal( total, 6, "Looping over an array" ); equal( total, 6, "Looping over an array" );
total = 0; total = 0;
jQuery.each([1,2,3], function(i,v){ total += v; if ( i == 1 ) return false; }); jQuery.each([1,2,3], function(i,v){
total += v;
if ( i == 1 ) {
return false;
}
});
equal( total, 3, "Looping over an array, with break" ); equal( total, 3, "Looping over an array, with break" );
total = 0; total = 0;
jQuery.each({"a":1,"b":2,"c":3}, function(i,v){ total += v; }); jQuery.each({"a":1,"b":2,"c":3}, function(i,v){ total += v; });
......
...@@ -73,21 +73,21 @@ test("css(String|Hash)", function() { ...@@ -73,21 +73,21 @@ test("css(String|Hash)", function() {
div = jQuery("#nothiddendiv"); div = jQuery("#nothiddendiv");
var child = jQuery("#nothiddendivchild"); var child = jQuery("#nothiddendivchild");
equal( parseInt(div.css("fontSize")), 16, "Verify fontSize px set." ); equal( parseInt(div.css("fontSize"), 10), 16, "Verify fontSize px set." );
equal( parseInt(div.css("font-size")), 16, "Verify fontSize px set." ); equal( parseInt(div.css("font-size"), 10), 16, "Verify fontSize px set." );
equal( parseInt(child.css("fontSize")), 16, "Verify fontSize px set." ); equal( parseInt(child.css("fontSize"), 10), 16, "Verify fontSize px set." );
equal( parseInt(child.css("font-size")), 16, "Verify fontSize px set." ); equal( parseInt(child.css("font-size"), 10), 16, "Verify fontSize px set." );
child.css("height", "100%"); child.css("height", "100%");
equal( child[0].style.height, "100%", "Make sure the height is being set correctly." ); equal( child[0].style.height, "100%", "Make sure the height is being set correctly." );
child.attr("class", "em"); child.attr("class", "em");
equal( parseInt(child.css("fontSize")), 32, "Verify fontSize em set." ); equal( parseInt(child.css("fontSize"), 10), 32, "Verify fontSize em set." );
// Have to verify this as the result depends upon the browser's CSS // Have to verify this as the result depends upon the browser's CSS
// support for font-size percentages // support for font-size percentages
child.attr("class", "prct"); child.attr("class", "prct");
var prctval = parseInt(child.css("fontSize")), checkval = 0; var prctval = parseInt(child.css("fontSize"), 10), checkval = 0;
if ( prctval === 16 || prctval === 24 ) { if ( prctval === 16 || prctval === 24 ) {
checkval = prctval; checkval = prctval;
} }
...@@ -314,8 +314,8 @@ test("css(String, Function)", function() { ...@@ -314,8 +314,8 @@ test("css(String, Function)", function() {
index = 0; index = 0;
jQuery("#cssFunctionTest div").each(function() { jQuery("#cssFunctionTest div").each(function() {
var computedSize = jQuery(this).css("font-size") var computedSize = jQuery(this).css("font-size");
var expectedSize = sizes[index] var expectedSize = sizes[index];
equal( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize ); equal( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize );
index++; index++;
}); });
...@@ -344,7 +344,7 @@ test("css(String, Function) with incoming value", function() { ...@@ -344,7 +344,7 @@ test("css(String, Function) with incoming value", function() {
index = 0; index = 0;
jQuery("#cssFunctionTest div").css("font-size", function(i, computedSize) { jQuery("#cssFunctionTest div").css("font-size", function(i, computedSize) {
var expectedSize = sizes[index] var expectedSize = sizes[index];
equal( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize ); equal( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize );
index++; index++;
return computedSize; return computedSize;
...@@ -374,8 +374,8 @@ test("css(Object) where values are Functions", function() { ...@@ -374,8 +374,8 @@ test("css(Object) where values are Functions", function() {
index = 0; index = 0;
jQuery("#cssFunctionTest div").each(function() { jQuery("#cssFunctionTest div").each(function() {
var computedSize = jQuery(this).css("font-size") var computedSize = jQuery(this).css("font-size");
var expectedSize = sizes[index] var expectedSize = sizes[index];
equal( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize ); equal( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize );
index++; index++;
}); });
...@@ -404,7 +404,7 @@ test("css(Object) where values are Functions with incoming values", function() { ...@@ -404,7 +404,7 @@ test("css(Object) where values are Functions with incoming values", function() {
index = 0; index = 0;
jQuery("#cssFunctionTest div").css({"font-size": function(i, computedSize) { jQuery("#cssFunctionTest div").css({"font-size": function(i, computedSize) {
var expectedSize = sizes[index] var expectedSize = sizes[index];
equal( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize ); equal( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize );
index++; index++;
return computedSize; return computedSize;
...@@ -444,7 +444,9 @@ test("show(); hide()", function() { ...@@ -444,7 +444,9 @@ test("show(); hide()", function() {
var pass = true; var pass = true;
div = jQuery("#qunit-fixture div"); div = jQuery("#qunit-fixture div");
div.show().each(function(){ div.show().each(function(){
if ( this.style.display == "none" ) pass = false; if ( this.style.display == "none" ) {
pass = false;
}
}); });
ok( pass, "Show" ); ok( pass, "Show" );
...@@ -700,7 +702,7 @@ test("can't get background-position in IE<9, see #10796", function() { ...@@ -700,7 +702,7 @@ test("can't get background-position in IE<9, see #10796", function() {
"12em center", "12em center",
"+12em center", "+12em center",
"12.2em center", "12.2em center",
"center center", "center center"
], ],
l = units.length, l = units.length,
i = 0; i = 0;
......
...@@ -18,10 +18,12 @@ function dataTests (elem) { ...@@ -18,10 +18,12 @@ function dataTests (elem) {
return cacheLength; return cacheLength;
} }
var oldCacheLength, dataObj, internalDataObj, expected, actual;
equal( jQuery.data(elem, "foo"), undefined, "No data exists initially" ); equal( jQuery.data(elem, "foo"), undefined, "No data exists initially" );
strictEqual( jQuery.hasData(elem), false, "jQuery.hasData agrees no data exists initially" ); strictEqual( jQuery.hasData(elem), false, "jQuery.hasData agrees no data exists initially" );
var dataObj = jQuery.data(elem); dataObj = jQuery.data(elem);
equal( typeof dataObj, "object", "Calling data with no args gives us a data object reference" ); equal( typeof dataObj, "object", "Calling data with no args gives us a data object reference" );
strictEqual( jQuery.data(elem), dataObj, "Calling jQuery.data returns the same data object when called multiple times" ); strictEqual( jQuery.data(elem), dataObj, "Calling jQuery.data returns the same data object when called multiple times" );
...@@ -52,7 +54,7 @@ function dataTests (elem) { ...@@ -52,7 +54,7 @@ function dataTests (elem) {
equal( jQuery._data(elem, "foo"), "foo2", "Setting internal data works" ); equal( jQuery._data(elem, "foo"), "foo2", "Setting internal data works" );
equal( jQuery.data(elem, "foo"), "foo1", "Setting internal data does not override user data" ); equal( jQuery.data(elem, "foo"), "foo1", "Setting internal data does not override user data" );
var internalDataObj = jQuery._data( elem ); internalDataObj = jQuery._data( elem );
ok( internalDataObj, "Internal data object exists" ); ok( internalDataObj, "Internal data object exists" );
notStrictEqual( dataObj, internalDataObj, "Internal data object is not the same as user data object" ); notStrictEqual( dataObj, internalDataObj, "Internal data object is not the same as user data object" );
...@@ -80,14 +82,14 @@ function dataTests (elem) { ...@@ -80,14 +82,14 @@ function dataTests (elem) {
jQuery.removeData( elem, "foo", true ); jQuery.removeData( elem, "foo", true );
if (elem.nodeType) { if (elem.nodeType) {
var oldCacheLength = getCacheLength(); oldCacheLength = getCacheLength();
jQuery.removeData(elem, "foo"); jQuery.removeData(elem, "foo");
equal( getCacheLength(), oldCacheLength - 1, "Removing the last item in the data object destroys it" ); equal( getCacheLength(), oldCacheLength - 1, "Removing the last item in the data object destroys it" );
} }
else { else {
jQuery.removeData(elem, "foo"); jQuery.removeData(elem, "foo");
var expected, actual;
if (jQuery.support.deleteExpando) { if (jQuery.support.deleteExpando) {
expected = false; expected = false;
...@@ -117,7 +119,7 @@ function dataTests (elem) { ...@@ -117,7 +119,7 @@ function dataTests (elem) {
jQuery.removeData(elem, "foo"); jQuery.removeData(elem, "foo");
equal( jQuery._data(elem, "foo"), "foo2", "(sanity check) jQuery.removeData for user data does not remove internal data" ); equal( jQuery._data(elem, "foo"), "foo2", "(sanity check) jQuery.removeData for user data does not remove internal data" );
if (elem.nodeType) { if ( elem.nodeType ) {
oldCacheLength = getCacheLength(); oldCacheLength = getCacheLength();
jQuery.removeData(elem, "foo", true); jQuery.removeData(elem, "foo", true);
equal( getCacheLength(), oldCacheLength - 1, "Removing the last item in the internal data object also destroys the user data object when it is empty" ); equal( getCacheLength(), oldCacheLength - 1, "Removing the last item in the internal data object also destroys the user data object when it is empty" );
...@@ -204,9 +206,9 @@ test(".data(String) and .data(String, Object)", function() { ...@@ -204,9 +206,9 @@ test(".data(String) and .data(String, Object)", function() {
div = parent.children(); div = parent.children();
parent parent
.bind("getData", function(){ ok( false, "getData bubbled." ) }) .bind("getData", function(){ ok( false, "getData bubbled." ); })
.bind("setData", function(){ ok( false, "setData bubbled." ) }) .bind("setData", function(){ ok( false, "setData bubbled." ); })
.bind("changeData", function(){ ok( false, "changeData bubbled." ) }); .bind("changeData", function(){ ok( false, "changeData bubbled." ); });
ok( div.data("test") === undefined, "Check for no data exists" ); ok( div.data("test") === undefined, "Check for no data exists" );
...@@ -319,7 +321,12 @@ test("data-* attributes", function() { ...@@ -319,7 +321,12 @@ test("data-* attributes", function() {
child.data("ignored", "cache"); child.data("ignored", "cache");
equal( child.data("ignored"), "cache", "Cached data used before DOM data-* fallback"); equal( child.data("ignored"), "cache", "Cached data used before DOM data-* fallback");
var obj = child.data(), obj2 = dummy.data(), check = [ "myobj", "ignored", "other" ], num = 0, num2 = 0; var prop,
obj = child.data(),
obj2 = dummy.data(),
check = [ "myobj", "ignored", "other" ],
num = 0,
num2 = 0;
dummy.remove(); dummy.remove();
...@@ -328,13 +335,13 @@ test("data-* attributes", function() { ...@@ -328,13 +335,13 @@ test("data-* attributes", function() {
ok( obj2[ check[i] ], "Make sure data- property exists when calling data-." ); ok( obj2[ check[i] ], "Make sure data- property exists when calling data-." );
} }
for ( var prop in obj ) { for ( prop in obj ) {
num++; num++;
} }
equal( num, check.length, "Make sure that the right number of properties came through." ); equal( num, check.length, "Make sure that the right number of properties came through." );
for ( var prop in obj2 ) { for ( prop in obj2 ) {
num2++; num2++;
} }
...@@ -397,7 +404,7 @@ test("data-* attributes", function() { ...@@ -397,7 +404,7 @@ test("data-* attributes", function() {
deepEqual(jQuery(elem).data("stuff"), [2,8], "Check stuff property"); deepEqual(jQuery(elem).data("stuff"), [2,8], "Check stuff property");
break; break;
default: default:
ok(false, ["Assertion failed on index ", index, ", with data ", data].join("")); ok(false, ["Assertion failed on index ", index, ", with data"].join(""));
} }
} }
......
...@@ -324,16 +324,20 @@ test( "jQuery.when" , function() { ...@@ -324,16 +324,20 @@ test( "jQuery.when" , function() {
strictEqual( this, context, "when( promise ) propagates context" ); strictEqual( this, context, "when( promise ) propagates context" );
}); });
var cache, i; var cache;
jQuery.each([ 1, 2, 3 ], function(k, i) {
for( i = 1 ; i < 4 ; i++ ) {
jQuery.when( cache || jQuery.Deferred( function() { jQuery.when( cache || jQuery.Deferred( function() {
this.resolve( i ); this.resolve( i );
}) ).done(function( value ) { })
strictEqual( value , 1 , "Function executed" + ( i > 1 ? " only once" : "" ) ); ).done(function( value ) {
strictEqual( value, 1 , "Function executed" + ( i > 1 ? " only once" : "" ) );
cache = value; cache = value;
}); });
}
});
}); });
test("jQuery.when - joined", function() { test("jQuery.when - joined", function() {
......
...@@ -2,13 +2,13 @@ if ( jQuery.fn.width ) { ...@@ -2,13 +2,13 @@ if ( jQuery.fn.width ) {
module("dimensions", { teardown: moduleTeardown }); module("dimensions", { teardown: moduleTeardown });
function pass( val ) { var pass = function( val ) {
return val; return val;
} };
function fn( val ) { var fn = function( val ) {
return function(){ return val; }; return function(){ return val; };
} };
/* /*
======== local reference ======= ======== local reference =======
...@@ -22,7 +22,7 @@ function fn( val ) { ...@@ -22,7 +22,7 @@ function fn( val ) {
Returns a function that returns the value Returns a function that returns the value
*/ */
function testWidth( val ) { var testWidth = function( val ) {
expect(9); expect(9);
var $div = jQuery("#nothiddendiv"); var $div = jQuery("#nothiddendiv");
...@@ -51,7 +51,7 @@ function testWidth( val ) { ...@@ -51,7 +51,7 @@ function testWidth( val ) {
equal( jQuery(window).width(), document.documentElement.clientWidth, "Window width is equal to width reported by window/document." ); equal( jQuery(window).width(), document.documentElement.clientWidth, "Window width is equal to width reported by window/document." );
jQuery.removeData($div[0], "olddisplay", true); jQuery.removeData($div[0], "olddisplay", true);
} };
test("width()", function() { test("width()", function() {
testWidth( pass ); testWidth( pass );
...@@ -73,7 +73,7 @@ test("width(Function(args))", function() { ...@@ -73,7 +73,7 @@ test("width(Function(args))", function() {
equal( $div.width(), 31, "Make sure value was modified correctly." ); equal( $div.width(), 31, "Make sure value was modified correctly." );
}); });
function testHeight( val ) { var testHeight = function( val ) {
expect(9); expect(9);
var $div = jQuery("#nothiddendiv"); var $div = jQuery("#nothiddendiv");
...@@ -102,7 +102,7 @@ function testHeight( val ) { ...@@ -102,7 +102,7 @@ function testHeight( val ) {
equal( jQuery(window).height(), document.documentElement.clientHeight, "Window width is equal to width reported by window/document." ); equal( jQuery(window).height(), document.documentElement.clientHeight, "Window width is equal to width reported by window/document." );
jQuery.removeData($div[0], "olddisplay", true); jQuery.removeData($div[0], "olddisplay", true);
} };
test("height()", function() { test("height()", function() {
testHeight( pass ); testHeight( pass );
......
...@@ -37,7 +37,9 @@ test("show()", function() { ...@@ -37,7 +37,9 @@ test("show()", function() {
var pass = true; var pass = true;
div = jQuery("#qunit-fixture div"); div = jQuery("#qunit-fixture div");
div.show().each(function(){ div.show().each(function(){
if ( this.style.display == "none" ) pass = false; if ( this.style.display == "none" ) {
pass = false;
}
}); });
ok( pass, "Show" ); ok( pass, "Show" );
...@@ -50,7 +52,9 @@ test("show()", function() { ...@@ -50,7 +52,9 @@ test("show()", function() {
jQuery.each(speeds, function(name, speed) { jQuery.each(speeds, function(name, speed) {
pass = true; pass = true;
div.hide().show(speed).each(function() { div.hide().show(speed).each(function() {
if ( this.style.display == "none" ) pass = false; if ( this.style.display == "none" ) {
pass = false;
}
}); });
ok( pass, "Show with " + name); ok( pass, "Show with " + name);
}); });
...@@ -874,16 +878,16 @@ jQuery.each({ ...@@ -874,16 +878,16 @@ jQuery.each({
} }
var num = 0; var num = 0;
// TODO: uncrowd this
if ( t_h == "show" ) num++; if ( t_h == "show" ) {num++;}
if ( t_w == "show" ) num++; if ( t_w == "show" ) {num++;}
if ( t_w == "hide" || t_w == "show" ) num++; if ( t_w == "hide" || t_w == "show" ) {num++;}
if ( t_h == "hide" || t_h == "show" ) num++; if ( t_h == "hide" || t_h == "show" ) {num++;}
if ( t_o == "hide" || t_o == "show" ) num++; if ( t_o == "hide" || t_o == "show" ) {num++;}
if ( t_w == "hide" ) num++; if ( t_w == "hide" ) {num++;}
if ( t_o.constructor == Number ) num += 2; if ( t_o.constructor == Number ) {num += 2;}
if ( t_w.constructor == Number ) num += 2; if ( t_w.constructor == Number ) {num += 2;}
if ( t_h.constructor == Number ) num +=2; if ( t_h.constructor == Number ) {num +=2;}
expect( num ); expect( num );
stop(); stop();
...@@ -935,7 +939,7 @@ jQuery.each({ ...@@ -935,7 +939,7 @@ jQuery.each({
if ( t_o.constructor == Number ) { if ( t_o.constructor == Number ) {
equal( cur_o, t_o, "Final opacity should be " + t_o + ": " + cur_o ); equal( cur_o, t_o, "Final opacity should be " + t_o + ": " + cur_o );
ok( jQuery.css(elem, "opacity") != "" || cur_o == t_o, "Opacity should be explicitly set to " + t_o + ", is instead: " + cur_o ); ok( jQuery.css(elem, "opacity") !== "" || cur_o == t_o, "Opacity should be explicitly set to " + t_o + ", is instead: " + cur_o );
} }
if ( t_w.constructor == Number ) { if ( t_w.constructor == Number ) {
...@@ -943,7 +947,7 @@ jQuery.each({ ...@@ -943,7 +947,7 @@ jQuery.each({
var cur_w = jQuery.css( elem,"width" ); var cur_w = jQuery.css( elem,"width" );
ok( elem.style.width != "" || cur_w == t_w, "Width should be explicitly set to " + t_w + ", is instead: " + cur_w ); ok( elem.style.width !== "" || cur_w == t_w, "Width should be explicitly set to " + t_w + ", is instead: " + cur_w );
} }
if ( t_h.constructor == Number ) { if ( t_h.constructor == Number ) {
...@@ -951,7 +955,7 @@ jQuery.each({ ...@@ -951,7 +955,7 @@ jQuery.each({
var cur_h = jQuery.css( elem,"height" ); var cur_h = jQuery.css( elem,"height" );
ok( elem.style.height != "" || cur_h == t_h, "Height should be explicitly set to " + t_h + ", is instead: " + cur_w ); ok( elem.style.height !== "" || cur_h == t_h, "Height should be explicitly set to " + t_h + ", is instead: " + cur_h );
} }
if ( t_h == "show" ) { if ( t_h == "show" ) {
...@@ -1154,17 +1158,17 @@ test("animate with per-property easing", function(){ ...@@ -1154,17 +1158,17 @@ test("animate with per-property easing", function(){
c: 100 c: 100
}; };
jQuery.easing["_test1"] = function(p) { jQuery.easing._test1 = function(p) {
_test1_called = true; _test1_called = true;
return p; return p;
}; };
jQuery.easing["_test2"] = function(p) { jQuery.easing._test2 = function(p) {
_test2_called = true; _test2_called = true;
return p; return p;
}; };
jQuery.easing["_default_test"] = function(p) { jQuery.easing._default_test = function(p) {
_default_test_called = true; _default_test_called = true;
return p; return p;
}; };
...@@ -1190,14 +1194,14 @@ test("animate with CSS shorthand properties", function(){ ...@@ -1190,14 +1194,14 @@ test("animate with CSS shorthand properties", function(){
propsBasic = { padding: "10 20 30" }, propsBasic = { padding: "10 20 30" },
propsSpecial = { padding: [ "1 2 3", "_special" ] }; propsSpecial = { padding: [ "1 2 3", "_special" ] };
jQuery.easing["_default"] = function(p) { jQuery.easing._default = function(p) {
if ( p >= 1 ) { if ( p >= 1 ) {
_default_count++; _default_count++;
} }
return p; return p;
}; };
jQuery.easing["_special"] = function(p) { jQuery.easing._special = function(p) {
if ( p >= 1 ) { if ( p >= 1 ) {
_special_count++; _special_count++;
} }
...@@ -1222,8 +1226,8 @@ test("animate with CSS shorthand properties", function(){ ...@@ -1222,8 +1226,8 @@ test("animate with CSS shorthand properties", function(){
equal( _special_count, 4, "special easing called for each property" ); equal( _special_count, 4, "special easing called for each property" );
jQuery(this).css("padding", "0"); jQuery(this).css("padding", "0");
delete jQuery.easing["_default"]; delete jQuery.easing._default;
delete jQuery.easing["_special"]; delete jQuery.easing._special;
start(); start();
}); });
}); });
...@@ -1306,7 +1310,7 @@ asyncTest( "callbacks that throw exceptions will be removed (#5684)", function() ...@@ -1306,7 +1310,7 @@ asyncTest( "callbacks that throw exceptions will be removed (#5684)", function()
} }
foo.animate({ height: 1 }, 1, function() { foo.animate({ height: 1 }, 1, function() {
throw new testException; throw new testException();
}); });
// this test thoroughly abuses undocumented methods - please feel free to update // this test thoroughly abuses undocumented methods - please feel free to update
...@@ -1393,7 +1397,7 @@ asyncTest( "Animate Option: step: function( percent, tween )", 1, function() { ...@@ -1393,7 +1397,7 @@ asyncTest( "Animate Option: step: function( percent, tween )", 1, function() {
}, { }, {
duration: 1, duration: 1,
step: function( value, tween ) { step: function( value, tween ) {
calls = counter[ tween.prop ] = counter[ tween.prop ] || []; var calls = counter[ tween.prop ] = counter[ tween.prop ] || [];
calls.push( value ); calls.push( value );
} }
}).queue( function( next ) { }).queue( function( next ) {
...@@ -1650,7 +1654,7 @@ asyncTest( "animate does not change start value for non-px animation (#7109)", 1 ...@@ -1650,7 +1654,7 @@ asyncTest( "animate does not change start value for non-px animation (#7109)", 1
} }
}).queue( function( next ) { }).queue( function( next ) {
var ratio = computed[ 0 ] / actual; var ratio = computed[ 0 ] / actual;
ok( ratio > .9 && ratio < 1.1 , "Starting width was close enough" ); ok( ratio > 0.9 && ratio < 1.1 , "Starting width was close enough" );
next(); next();
start(); start();
}); });
......
This diff is collapsed.
This diff is collapsed.
...@@ -86,8 +86,8 @@ testIframe("offset/absolute", "absolute", function( jQuery ) { ...@@ -86,8 +86,8 @@ testIframe("offset/absolute", "absolute", function( jQuery ) {
// test #5781 // test #5781
var offset = jQuery( "#positionTest" ).offset({ top: 10, left: 10 }).offset(); var offset = jQuery( "#positionTest" ).offset({ top: 10, left: 10 }).offset();
equal( offset.top, 10, "Setting offset on element with position absolute but 'auto' values." ) equal( offset.top, 10, "Setting offset on element with position absolute but 'auto' values." );
equal( offset.left, 10, "Setting offset on element with position absolute but 'auto' values." ) equal( offset.left, 10, "Setting offset on element with position absolute but 'auto' values." );
// set offset // set offset
......
...@@ -60,7 +60,7 @@ test("queue(name) passes in the next item in the queue as a parameter", function ...@@ -60,7 +60,7 @@ test("queue(name) passes in the next item in the queue as a parameter", function
equal(++counter, 2, "Next was called"); equal(++counter, 2, "Next was called");
next(); next();
}).queue("bar", function() { }).queue("bar", function() {
equal(++counter, 3, "Other queues are not triggered by next()") equal(++counter, 3, "Other queues are not triggered by next()");
}); });
div.dequeue("foo"); div.dequeue("foo");
...@@ -76,12 +76,12 @@ test("queue() passes in the next item in the queue as a parameter to fx queues", ...@@ -76,12 +76,12 @@ test("queue() passes in the next item in the queue as a parameter to fx queues",
div.queue(function(next) { div.queue(function(next) {
equal(++counter, 1, "Dequeueing"); equal(++counter, 1, "Dequeueing");
var self = this; var self = this;
setTimeout(function() { next() }, 500); setTimeout(function() { next(); }, 500);
}).queue(function(next) { }).queue(function(next) {
equal(++counter, 2, "Next was called"); equal(++counter, 2, "Next was called");
next(); next();
}).queue("bar", function() { }).queue("bar", function() {
equal(++counter, 3, "Other queues are not triggered by next()") equal(++counter, 3, "Other queues are not triggered by next()");
}); });
jQuery.when( div.promise("fx"), div ).done(function() { jQuery.when( div.promise("fx"), div ).done(function() {
...@@ -136,7 +136,7 @@ test("delay()", function() { ...@@ -136,7 +136,7 @@ test("delay()", function() {
test("clearQueue(name) clears the queue", function() { test("clearQueue(name) clears the queue", function() {
expect(2); expect(2);
stop() stop();
var div = jQuery({}); var div = jQuery({});
var counter = 0; var counter = 0;
......
...@@ -12,8 +12,8 @@ test("element - jQuery only", function() { ...@@ -12,8 +12,8 @@ test("element - jQuery only", function() {
deepEqual( jQuery("p", jQuery("div")).get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." ); deepEqual( jQuery("p", jQuery("div")).get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." );
deepEqual( jQuery("div").find("p").get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." ); deepEqual( jQuery("div").find("p").get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." );
ok( jQuery("#length").length, "\<input name=\"length\"\> cannot be found under IE, see #945" ); ok( jQuery("#length").length, "<input name=\"length\"> cannot be found under IE, see #945" );
ok( jQuery("#lengthtest input").length, "\<input name=\"length\"\> cannot be found under IE, see #945" ); ok( jQuery("#lengthtest input").length, "<input name=\"length\"> cannot be found under IE, see #945" );
//#7533 //#7533
equal( jQuery("<div id=\"A'B~C.D[E]\"><p>foo</p></div>").find("p").length, 1, "Find where context root is a node and has an ID with CSS3 meta characters" ); equal( jQuery("<div id=\"A'B~C.D[E]\"><p>foo</p></div>").find("p").length, 1, "Find where context root is a node and has an ID with CSS3 meta characters" );
......
...@@ -256,5 +256,3 @@ testIframeWithCallback( "A background on the testElement does not cause IE8 to c ...@@ -256,5 +256,3 @@ testIframeWithCallback( "A background on the testElement does not cause IE8 to c
} }
})(); })();
...@@ -202,9 +202,11 @@ test("filter(Selector|undefined)", function() { ...@@ -202,9 +202,11 @@ test("filter(Selector|undefined)", function() {
test("filter(Function)", function() { test("filter(Function)", function() {
expect(2); expect(2);
deepEqual( jQuery("#qunit-fixture p").filter(function() { return !jQuery("a", this).length }).get(), q("sndp", "first"), "filter(Function)" ); deepEqual( jQuery("#qunit-fixture p").filter(function() {
return !jQuery("a", this).length;
}).get(), q("sndp", "first"), "filter(Function)" );
deepEqual( jQuery("#qunit-fixture p").filter(function(i, elem) { return !jQuery("a", elem).length }).get(), q("sndp", "first"), "filter(Function) using arg" ); deepEqual( jQuery("#qunit-fixture p").filter(function(i, elem) { return !jQuery("a", elem).length; }).get(), q("sndp", "first"), "filter(Function) using arg" );
}); });
test("filter(Element)", function() { test("filter(Element)", function() {
...@@ -341,7 +343,7 @@ test("not(Element)", function() { ...@@ -341,7 +343,7 @@ test("not(Element)", function() {
}); });
test("not(Function)", function() { test("not(Function)", function() {
deepEqual( jQuery("#qunit-fixture p").not(function() { return jQuery("a", this).length }).get(), q("sndp", "first"), "not(Function)" ); deepEqual( jQuery("#qunit-fixture p").not(function() { return jQuery("a", this).length; }).get(), q("sndp", "first"), "not(Function)" );
}); });
test("not(Array)", function() { test("not(Array)", function() {
...@@ -600,15 +602,15 @@ test("add(String|Element|Array|undefined)", function() { ...@@ -600,15 +602,15 @@ test("add(String|Element|Array|undefined)", function() {
equal( x[0].id, "x1", "Check on-the-fly element1" ); equal( x[0].id, "x1", "Check on-the-fly element1" );
equal( x[1].id, "x2", "Check on-the-fly element2" ); equal( x[1].id, "x2", "Check on-the-fly element2" );
var x = jQuery([]).add(jQuery("<p id='x1'>xxx</p>").appendTo(tmp)[0]).add(jQuery("<p id='x2'>xxx</p>").appendTo(tmp)[0]); x = jQuery([]).add(jQuery("<p id='x1'>xxx</p>").appendTo(tmp)[0]).add(jQuery("<p id='x2'>xxx</p>").appendTo(tmp)[0]);
equal( x[0].id, "x1", "Check on-the-fly element1" ); equal( x[0].id, "x1", "Check on-the-fly element1" );
equal( x[1].id, "x2", "Check on-the-fly element2" ); equal( x[1].id, "x2", "Check on-the-fly element2" );
var x = jQuery([]).add(jQuery("<p id='x1'>xxx</p>")).add(jQuery("<p id='x2'>xxx</p>")); x = jQuery([]).add(jQuery("<p id='x1'>xxx</p>")).add(jQuery("<p id='x2'>xxx</p>"));
equal( x[0].id, "x1", "Check on-the-fly element1" ); equal( x[0].id, "x1", "Check on-the-fly element1" );
equal( x[1].id, "x2", "Check on-the-fly element2" ); equal( x[1].id, "x2", "Check on-the-fly element2" );
var x = jQuery([]).add("<p id='x1'>xxx</p>").add("<p id='x2'>xxx</p>"); x = jQuery([]).add("<p id='x1'>xxx</p>").add("<p id='x2'>xxx</p>");
equal( x[0].id, "x1", "Check on-the-fly element1" ); equal( x[0].id, "x1", "Check on-the-fly element1" );
equal( x[1].id, "x2", "Check on-the-fly element2" ); equal( x[1].id, "x2", "Check on-the-fly element2" );
...@@ -640,4 +642,3 @@ test("eq('-1') #10616", function() { ...@@ -640,4 +642,3 @@ test("eq('-1') #10616", function() {
equal( $divs.eq( "-1" ).length, 1, "The string '-1' returns a selection that has length 1" ); equal( $divs.eq( "-1" ).length, 1, "The string '-1' returns a selection that has length 1" );
deepEqual( $divs.eq( "-1" ), $divs.eq( -1 ), "String and number -1 match" ); deepEqual( $divs.eq( "-1" ), $divs.eq( -1 ), "String and number -1 match" );
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment