Commit 4bda398e authored by John Resig's avatar John Resig

Switched from using QUnit's isObj/isSet to the more robust same method.

parent f8b7d391
...@@ -29,7 +29,7 @@ test("jQuery()", function() { ...@@ -29,7 +29,7 @@ test("jQuery()", function() {
var main = jQuery("#main"); var main = jQuery("#main");
isSet( jQuery("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" ); same( 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 // disabled since this test was doing nothing. i tried to fix it but i'm not sure
...@@ -376,12 +376,12 @@ test("size()", function() { ...@@ -376,12 +376,12 @@ test("size()", function() {
test("get()", function() { test("get()", function() {
expect(1); expect(1);
isSet( jQuery("p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" ); same( jQuery("p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" );
}); });
test("toArray()", function() { test("toArray()", function() {
expect(1); expect(1);
isSet ( jQuery("p").toArray(), same( jQuery("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" )
}) })
...@@ -400,8 +400,8 @@ test("get(-Number)",function() { ...@@ -400,8 +400,8 @@ test("get(-Number)",function() {
test("add(String|Element|Array|undefined)", function() { test("add(String|Element|Array|undefined)", function() {
expect(16); expect(16);
isSet( jQuery("#sndp").add("#en").add("#sap").get(), q("sndp", "en", "sap"), "Check elements from document" ); same( jQuery("#sndp").add("#en").add("#sap").get(), q("sndp", "en", "sap"), "Check elements from document" );
isSet( jQuery("#sndp").add( jQuery("#en")[0] ).add( jQuery("#sap") ).get(), q("sndp", "en", "sap"), "Check elements from document" ); same( jQuery("#sndp").add( jQuery("#en")[0] ).add( jQuery("#sap") ).get(), q("sndp", "en", "sap"), "Check elements from document" );
ok( jQuery([]).add(jQuery("#form")[0].elements).length >= 13, "Check elements from array" ); ok( jQuery([]).add(jQuery("#form")[0].elements).length >= 13, "Check elements from array" );
// For the time being, we're discontinuing support for jQuery(form.elements) since it's ambiguous in IE // For the time being, we're discontinuing support for jQuery(form.elements) since it's ambiguous in IE
...@@ -515,33 +515,33 @@ test("jQuery.extend(Object, Object)", function() { ...@@ -515,33 +515,33 @@ test("jQuery.extend(Object, Object)", function() {
deepmerged = { foo: { bar: true, baz: true }, foo2: document }; deepmerged = { foo: { bar: true, baz: true }, foo2: document };
jQuery.extend(settings, options); jQuery.extend(settings, options);
isObj( settings, merged, "Check if extended: settings must be extended" ); same( settings, merged, "Check if extended: settings must be extended" );
isObj( options, optionsCopy, "Check if not modified: options must not be modified" ); same( options, optionsCopy, "Check if not modified: options must not be modified" );
jQuery.extend(settings, null, options); jQuery.extend(settings, null, options);
isObj( settings, merged, "Check if extended: settings must be extended" ); same( settings, merged, "Check if extended: settings must be extended" );
isObj( options, optionsCopy, "Check if not modified: options must not be modified" ); same( options, optionsCopy, "Check if not modified: options must not be modified" );
jQuery.extend(true, deep1, deep2); jQuery.extend(true, deep1, deep2);
isObj( deep1.foo, deepmerged.foo, "Check if foo: settings must be extended" ); same( deep1.foo, deepmerged.foo, "Check if foo: settings must be extended" );
isObj( deep2.foo, deep2copy.foo, "Check if not deep2: options must not be modified" ); 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" ); equals( deep1.foo2, document, "Make sure that a deep clone was not attempted on the document" );
var empty = {}; var empty = {};
var optionsWithLength = { foo: { length: -1 } }; var optionsWithLength = { foo: { length: -1 } };
jQuery.extend(true, empty, optionsWithLength); jQuery.extend(true, empty, optionsWithLength);
isObj( empty.foo, optionsWithLength.foo, "The length property must copy correctly" ); same( 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);
isObj( empty.foo, optionsWithDate.foo, "Dates copy correctly" ); same( empty.foo, optionsWithDate.foo, "Dates copy correctly" );
var myKlass = function() {}; var myKlass = function() {};
empty = {}; empty = {};
var optionsWithCustomObject = { foo: { date: new myKlass } }; var optionsWithCustomObject = { foo: { date: new myKlass } };
jQuery.extend(true, empty, optionsWithCustomObject); jQuery.extend(true, empty, optionsWithCustomObject);
isObj( empty.foo, optionsWithCustomObject.foo, "Custom objects copy correctly" ); same( empty.foo, optionsWithCustomObject.foo, "Custom objects copy correctly" );
var nullUndef; var nullUndef;
nullUndef = jQuery.extend({}, options, { xnumber2: null }); nullUndef = jQuery.extend({}, options, { xnumber2: null });
...@@ -556,7 +556,7 @@ test("jQuery.extend(Object, Object)", function() { ...@@ -556,7 +556,7 @@ test("jQuery.extend(Object, Object)", function() {
var target = {}; var target = {};
var recursive = { foo:target, bar:5 }; var recursive = { foo:target, bar:5 };
jQuery.extend(true, target, recursive); jQuery.extend(true, target, recursive);
isObj( target, { bar:5 }, "Check to make sure a recursive obj doesn't go never-ending loop by not copying it over" ); same( 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 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" ); equals( ret.foo.length, 1, "Check to make sure a value with coersion 'false' copies over when necessary to fix #1907" );
...@@ -584,10 +584,10 @@ test("jQuery.extend(Object, Object)", function() { ...@@ -584,10 +584,10 @@ test("jQuery.extend(Object, Object)", function() {
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); var settings = jQuery.extend({}, defaults, options1, options2);
isObj( settings, merged2, "Check if extended: settings must be extended" ); same( settings, merged2, "Check if extended: settings must be extended" );
isObj( defaults, defaultsCopy, "Check if not modified: options1 must not be modified" ); same( defaults, defaultsCopy, "Check if not modified: options1 must not be modified" );
isObj( options1, options1Copy, "Check if not modified: options1 must not be modified" ); same( options1, options1Copy, "Check if not modified: options1 must not be modified" );
isObj( options2, options2Copy, "Check if not modified: options2 must not be modified" ); same( options2, options2Copy, "Check if not modified: options2 must not be modified" );
}); });
test("jQuery.each(Object,Function)", function() { test("jQuery.each(Object,Function)", function() {
......
...@@ -50,7 +50,7 @@ test(".data()", function() { ...@@ -50,7 +50,7 @@ test(".data()", function() {
var div = jQuery("#foo"); var div = jQuery("#foo");
div.data("test", "success"); div.data("test", "success");
isObj( div.data(), {test: "success"}, "data() get the entire data object" ) same( div.data(), {test: "success"}, "data() get the entire data object" )
}) })
test(".data(String) and .data(String, Object)", function() { test(".data(String) and .data(String, Object)", function() {
......
...@@ -57,7 +57,7 @@ test("animate option (queue === false)", function () { ...@@ -57,7 +57,7 @@ test("animate option (queue === false)", function () {
$foo.animate({width:'100px'}, 3000, function () { $foo.animate({width:'100px'}, 3000, function () {
// should finish after unqueued animation so second // should finish after unqueued animation so second
order.push(2); order.push(2);
isSet( order, [ 1, 2 ], "Animations finished in the correct order" ); same( order, [ 1, 2 ], "Animations finished in the correct order" );
start(); start();
}); });
$foo.animate({fontSize:'2em'}, {queue:false, duration:10, complete:function () { $foo.animate({fontSize:'2em'}, {queue:false, duration:10, complete:function () {
......
...@@ -602,7 +602,7 @@ test("val()", function() { ...@@ -602,7 +602,7 @@ test("val()", function() {
equals( jQuery('#select2').val(), '3', 'Call val() on a single="single" select' ); equals( jQuery('#select2').val(), '3', 'Call val() on a single="single" select' );
isSet( jQuery('#select3').val(), ['1', '2'], 'Call val() on a multiple="multiple" select' ); same( jQuery('#select3').val(), ['1', '2'], 'Call val() on a multiple="multiple" select' );
equals( jQuery('#option3c').val(), '2', 'Call val() on a option element with value' ); equals( jQuery('#option3c').val(), '2', 'Call val() on a option element with value' );
......
...@@ -16,17 +16,17 @@ test("element", function() { ...@@ -16,17 +16,17 @@ test("element", function() {
t( "Parent Element", "div p", ["firstp","ap","sndp","en","sap","first"] ); t( "Parent Element", "div p", ["firstp","ap","sndp","en","sap","first"] );
equals( jQuery("param", "#object1").length, 2, "Object/param as context" ); equals( jQuery("param", "#object1").length, 2, "Object/param as context" );
isSet( jQuery("p", document.getElementsByTagName("div")), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." ); same( jQuery("p", document.getElementsByTagName("div")).get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." );
isSet( jQuery("p", "div"), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." ); same( jQuery("p", "div").get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." );
isSet( jQuery("p", jQuery("div")), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." ); same( jQuery("p", jQuery("div")).get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." );
isSet( jQuery("div").find("p"), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." ); same( 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' );
// Check for unique-ness and sort order // Check for unique-ness and sort order
isSet( jQuery("*"), jQuery("*, *"), "Check for duplicates: *, *" ); same( jQuery("*").get(), jQuery("*, *").get(), "Check for duplicates: *, *" );
isSet( jQuery("p"), jQuery("p, div p"), "Check for duplicates: p, div p" ); same( jQuery("p").get(), jQuery("p, div p").get(), "Check for duplicates: p, div p" );
t( "Checking sort order", "h2, h1", ["header", "banner", "userAgent"] ); t( "Checking sort order", "h2, h1", ["header", "banner", "userAgent"] );
t( "Checking sort order", "h2:first, h1:first", ["header", "banner"] ); t( "Checking sort order", "h2:first, h1:first", ["header", "banner"] );
...@@ -103,7 +103,7 @@ test("id", function() { ...@@ -103,7 +103,7 @@ test("id", function() {
t( "ID selector with non-existant ancestor", "#asdfasdf #foobar", [] ); // bug #986 t( "ID selector with non-existant ancestor", "#asdfasdf #foobar", [] ); // bug #986
isSet( jQuery("body").find("div#form"), [], "ID selector within the context of another element" ); same( jQuery("body").find("div#form").get(), [], "ID selector within the context of another element" );
t( "Underscore ID", "#types_all", ["types_all"] ); t( "Underscore ID", "#types_all", ["types_all"] );
t( "Dash ID", "#fx-queue", ["fx-queue"] ); t( "Dash ID", "#fx-queue", ["fx-queue"] );
...@@ -119,10 +119,10 @@ test("class", function() { ...@@ -119,10 +119,10 @@ test("class", function() {
t( "Class Selector w/ Element", "a.blog", ["mark","simon"] ); t( "Class Selector w/ Element", "a.blog", ["mark","simon"] );
t( "Parent Class Selector", "p .blog", ["mark","simon"] ); t( "Parent Class Selector", "p .blog", ["mark","simon"] );
isSet( jQuery(".blog", document.getElementsByTagName("p")), q("mark", "simon"), "Finding elements with a context." ); same( jQuery(".blog", document.getElementsByTagName("p")).get(), q("mark", "simon"), "Finding elements with a context." );
isSet( jQuery(".blog", "p"), q("mark", "simon"), "Finding elements with a context." ); same( jQuery(".blog", "p").get(), q("mark", "simon"), "Finding elements with a context." );
isSet( jQuery(".blog", jQuery("p")), q("mark", "simon"), "Finding elements with a context." ); same( jQuery(".blog", jQuery("p")).get(), q("mark", "simon"), "Finding elements with a context." );
isSet( jQuery("p").find(".blog"), q("mark", "simon"), "Finding elements with a context." ); same( jQuery("p").find(".blog").get(), q("mark", "simon"), "Finding elements with a context." );
t( "Class selector using UTF8", ".台北Táiběi", ["utf8class1"] ); t( "Class selector using UTF8", ".台北Táiběi", ["utf8class1"] );
//t( "Class selector using UTF8", ".台北", ["utf8class1","utf8class2"] ); //t( "Class selector using UTF8", ".台北", ["utf8class1","utf8class2"] );
...@@ -140,11 +140,11 @@ test("class", function() { ...@@ -140,11 +140,11 @@ test("class", function() {
var div = document.createElement("div"); var div = document.createElement("div");
div.innerHTML = "<div class='test e'></div><div class='test'></div>"; div.innerHTML = "<div class='test e'></div><div class='test'></div>";
isSet( jQuery(".e", div), [ div.firstChild ], "Finding a second class." ); same( jQuery(".e", div).get(), [ div.firstChild ], "Finding a second class." );
div.lastChild.className = "e"; div.lastChild.className = "e";
isSet( jQuery(".e", div), [ div.firstChild, div.lastChild ], "Finding a modified class." ); same( jQuery(".e", div).get(), [ div.firstChild, div.lastChild ], "Finding a modified class." );
}); });
test("name", function() { test("name", function() {
...@@ -160,8 +160,8 @@ test("name", function() { ...@@ -160,8 +160,8 @@ test("name", function() {
t( "Name selector for grouped input", "input[name='types[]']", ["types_all", "types_anime", "types_movie"] ) t( "Name selector for grouped input", "input[name='types[]']", ["types_all", "types_anime", "types_movie"] )
isSet( jQuery("#form").find("input[name=action]"), q("text1"), "Name selector within the context of another element" ); same( jQuery("#form").find("input[name=action]").get(), q("text1"), "Name selector within the context of another element" );
isSet( jQuery("#form").find("input[name='foo[bar]']"), q("hidden2"), "Name selector for grouped form element within the context of another element" ); same( jQuery("#form").find("input[name='foo[bar]']").get(), q("hidden2"), "Name selector for grouped form element within the context of another element" );
var a = jQuery('<a id="tName1ID" name="tName1">tName1 A</a><a id="tName2ID" name="tName2">tName2 A</a><div id="tName1">tName1 Div</div>').appendTo('#main'); var a = jQuery('<a id="tName1ID" name="tName1">tName1 A</a><a id="tName2ID" name="tName2">tName2 A</a><div id="tName1">tName1 Div</div>').appendTo('#main');
...@@ -205,9 +205,9 @@ test("child and adjacent", function() { ...@@ -205,9 +205,9 @@ test("child and adjacent", function() {
t( "No element deep selector", "div.foo > span > a", [] ); t( "No element deep selector", "div.foo > span > a", [] );
t( "No element not selector", ".container div:not(.excluded) div", [] ); t( "No element not selector", ".container div:not(.excluded) div", [] );
isSet( jQuery("> :first", document.getElementById("nothiddendiv")), q("nothiddendivchild"), "Verify child context positional selctor" ); same( jQuery("> :first", document.getElementById("nothiddendiv")).get(), q("nothiddendivchild"), "Verify child context positional selctor" );
isSet( jQuery("> :eq(0)", document.getElementById("nothiddendiv")), q("nothiddendivchild"), "Verify child context positional selctor" ); same( jQuery("> :eq(0)", document.getElementById("nothiddendiv")).get(), q("nothiddendivchild"), "Verify child context positional selctor" );
isSet( jQuery("> *:first", document.getElementById("nothiddendiv")), q("nothiddendivchild"), "Verify child context positional selctor" ); same( jQuery("> *:first", document.getElementById("nothiddendiv")).get(), q("nothiddendivchild"), "Verify child context positional selctor" );
t( "Non-existant ancestors", ".fototab > .thumbnails > a", [] ); t( "Non-existant ancestors", ".fototab > .thumbnails > a", [] );
......
This diff is collapsed.
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