diff --git a/test/unit/core.js b/test/unit/core.js
index bfaceca38..6d2ff6b9d 100644
--- a/test/unit/core.js
+++ b/test/unit/core.js
@@ -13,10 +13,10 @@ test("Basic requirements", function() {
test("$()", function() {
expect(8);
-
+
var main = $("#main");
isSet( $("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
// what the expected behavior should even be. FF returns "\n" for the text node
@@ -25,7 +25,7 @@ test("$()", function() {
var x = crlfContainer.contents().get(0).nodeValue;
equals( x, what???, "Check for \\r and \\n in jQuery()" );
*/
-
+
/* // Disabled until we add this functionality in
var pass = true;
try {
@@ -41,14 +41,14 @@ test("$()", function() {
equals( img.length, 1, "Correct number of elements generated for img" );
var div = $("
");
equals( div.length, 4, "Correct number of elements generated for div hr code b" );
-
+
// can actually yield more than one, when iframes are included, the window is an array as well
equals( $(window).length, 1, "Correct number of elements generated for window" );
-
+
equals( $(document).length, 1, "Correct number of elements generated for document" );
-
+
equals( $([1,2,3]).get(1), 2, "Test passing an array to the factory" );
-
+
equals( $(document.body).get(0), $('body').get(0), "Test passing an html node to the factory" );
});
@@ -90,7 +90,7 @@ test("browser", function() {
test("noConflict", function() {
expect(6);
-
+
var old = jQuery;
var newjQuery = jQuery.noConflict();
@@ -156,7 +156,7 @@ test("isFunction", function() {
ok( !jQuery.isFunction(nodes), "childNodes Property" );
var first = document.body.firstChild;
-
+
// Normal elements are reported ok everywhere
ok( !jQuery.isFunction(first), "A normal DOM Element" );
@@ -206,10 +206,10 @@ test("$('html')", function() {
ok( !foo, "Make sure the script wasn't executed prematurely" );
$("body").append(s);
ok( foo, "Executing a scripts contents in the right context" );
-
+
reset();
ok( $("")[0], "Creating a link" );
-
+
reset();
var j = $("hi there ");
@@ -230,7 +230,7 @@ if ( !isLocal ) {
test("$(selector, xml).text(str) - Loaded via XML document", function() {
expect(2);
stop();
- $.get('data/dashboard.xml', function(xml) {
+ $.get('data/dashboard.xml', function(xml) {
// tests for #1419 where IE was a problem
equals( $("tab:first", xml).text(), "blabla", "Verify initial text correct" );
$("tab:first", xml).text("newtext");
@@ -269,18 +269,18 @@ test("add(String|Element|Array|undefined)", function() {
// For the time being, we're discontinuing support for $(form.elements) since it's ambiguous in IE
// use $([]).add(form.elements) instead.
//equals( $([]).add($("#form")[0].elements).length, $($("#form")[0].elements).length, "Array in constructor must equals array in add()" );
-
+
var x = $([]).add($("
');
ok( $('#table caption').length, "Append caption" );
@@ -731,7 +752,7 @@ test("append(String|Element|Array<Element>|jQuery)", function() {
$('form:last')
.append('')
.append('');
-
+
t( "Append Select", "#appendSelect1, #appendSelect2", ["appendSelect1", "appendSelect2"] );
// using contents will get comments regular, text, and comment nodes
@@ -750,22 +771,22 @@ test("appendTo(String|Element|Array<Element>|jQuery)", function() {
$('buga').appendTo('#first');
equals( $("#first").text(), defaultText + 'buga', 'Check if text appending works' );
equals( $('').appendTo('#select3').parent().find('option:last-child').attr('value'), 'appendTest', 'Appending html options to select element');
-
+
reset();
var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
$(document.getElementById('first')).appendTo('#sap');
equals( expected, $('#sap').text(), "Check for appending of element" );
-
+
reset();
expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
$([document.getElementById('first'), document.getElementById('yahoo')]).appendTo('#sap');
equals( expected, $('#sap').text(), "Check for appending of array of elements" );
-
+
reset();
expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
$("#first, #yahoo").appendTo('#sap');
equals( expected, $('#sap').text(), "Check for appending of jQuery object" );
-
+
reset();
$('#select1').appendTo('#foo');
t( 'Append select', '#foo select', ['select1'] );
@@ -777,7 +798,7 @@ test("prepend(String|Element|Array<Element>|jQuery)", function() {
var result = $('#first').prepend('buga');
equals( result.text(), 'buga' + defaultText, 'Check if text prepending works' );
equals( $('#select3').prepend('').find('option:first-child').attr('value'), 'prependTest', 'Prepending html options to select element');
-
+
reset();
var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
$('#sap').prepend(document.getElementById('first'));
@@ -787,7 +808,7 @@ test("prepend(String|Element|Array<Element>|jQuery)", function() {
expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
$('#sap').prepend([document.getElementById('first'), document.getElementById('yahoo')]);
equals( expected, $('#sap').text(), "Check for prepending of array of elements" );
-
+
reset();
expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
$('#sap').prepend($("#first, #yahoo"));
@@ -800,7 +821,7 @@ test("prependTo(String|Element|Array<Element>|jQuery)", function() {
$('buga').prependTo('#first');
equals( $('#first').text(), 'buga' + defaultText, 'Check if text prepending works' );
equals( $('').prependTo('#select3').parent().find('option:first-child').attr('value'), 'prependTest', 'Prepending html options to select element');
-
+
reset();
var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
$(document.getElementById('first')).prependTo('#sap');
@@ -810,16 +831,16 @@ test("prependTo(String|Element|Array<Element>|jQuery)", function() {
expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
$([document.getElementById('yahoo'), document.getElementById('first')]).prependTo('#sap');
equals( expected, $('#sap').text(), "Check for prepending of array of elements" );
-
+
reset();
expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
$("#yahoo, #first").prependTo('#sap');
equals( expected, $('#sap').text(), "Check for prepending of jQuery object" );
-
+
reset();
$('').prependTo('form:last');
$('').prependTo('form:last');
-
+
t( "Prepend Select", "#prependSelect1, #prependSelect2", ["prependSelect1", "prependSelect2"] );
});
@@ -828,17 +849,17 @@ test("before(String|Element|Array<Element>|jQuery)", function() {
var expected = 'This is a normal link: bugaYahoo';
$('#yahoo').before('buga');
equals( expected, $('#en').text(), 'Insert String before' );
-
+
reset();
expected = "This is a normal link: Try them out:Yahoo";
$('#yahoo').before(document.getElementById('first'));
equals( expected, $('#en').text(), "Insert element before" );
-
+
reset();
expected = "This is a normal link: Try them out:diveintomarkYahoo";
$('#yahoo').before([document.getElementById('first'), document.getElementById('mark')]);
equals( expected, $('#en').text(), "Insert array of elements before" );
-
+
reset();
expected = "This is a normal link: Try them out:diveintomarkYahoo";
$('#yahoo').before($("#first, #mark"));
@@ -850,17 +871,17 @@ test("insertBefore(String|Element|Array<Element>|jQuery)", function() {
var expected = 'This is a normal link: bugaYahoo';
$('buga').insertBefore('#yahoo');
equals( expected, $('#en').text(), 'Insert String before' );
-
+
reset();
expected = "This is a normal link: Try them out:Yahoo";
$(document.getElementById('first')).insertBefore('#yahoo');
equals( expected, $('#en').text(), "Insert element before" );
-
+
reset();
expected = "This is a normal link: Try them out:diveintomarkYahoo";
$([document.getElementById('first'), document.getElementById('mark')]).insertBefore('#yahoo');
equals( expected, $('#en').text(), "Insert array of elements before" );
-
+
reset();
expected = "This is a normal link: Try them out:diveintomarkYahoo";
$("#first, #mark").insertBefore('#yahoo');
@@ -872,7 +893,7 @@ test("after(String|Element|Array<Element>|jQuery)", function() {
var expected = 'This is a normal link: Yahoobuga';
$('#yahoo').after('buga');
equals( expected, $('#en').text(), 'Insert String after' );
-
+
reset();
expected = "This is a normal link: YahooTry them out:";
$('#yahoo').after(document.getElementById('first'));
@@ -882,7 +903,7 @@ test("after(String|Element|Array<Element>|jQuery)", function() {
expected = "This is a normal link: YahooTry them out:diveintomark";
$('#yahoo').after([document.getElementById('first'), document.getElementById('mark')]);
equals( expected, $('#en').text(), "Insert array of elements after" );
-
+
reset();
expected = "This is a normal link: YahooTry them out:diveintomark";
$('#yahoo').after($("#first, #mark"));
@@ -894,7 +915,7 @@ test("insertAfter(String|Element|Array<Element>|jQuery)", function() {
var expected = 'This is a normal link: Yahoobuga';
$('buga').insertAfter('#yahoo');
equals( expected, $('#en').text(), 'Insert String after' );
-
+
reset();
expected = "This is a normal link: YahooTry them out:";
$(document.getElementById('first')).insertAfter('#yahoo');
@@ -904,7 +925,7 @@ test("insertAfter(String|Element|Array<Element>|jQuery)", function() {
expected = "This is a normal link: YahooTry them out:diveintomark";
$([document.getElementById('mark'), document.getElementById('first')]).insertAfter('#yahoo');
equals( expected, $('#en').text(), "Insert array of elements after" );
-
+
reset();
expected = "This is a normal link: YahooTry them out:diveintomark";
$("#mark, #first").insertAfter('#yahoo');
@@ -916,7 +937,7 @@ test("replaceWith(String|Element|Array<Element>|jQuery)", function() {
$('#yahoo').replaceWith('buga');
ok( $("#replace")[0], 'Replace element with string' );
ok( !$("#yahoo")[0], 'Verify that original element is gone, after string' );
-
+
reset();
$('#yahoo').replaceWith(document.getElementById('first'));
ok( $("#first")[0], 'Replace element with element' );
@@ -927,7 +948,7 @@ test("replaceWith(String|Element|Array<Element>|jQuery)", function() {
ok( $("#first")[0], 'Replace element with array of elements' );
ok( $("#mark")[0], 'Replace element with array of elements' );
ok( !$("#yahoo")[0], 'Verify that original element is gone, after array of elements' );
-
+
reset();
$('#yahoo').replaceWith($("#first, #mark"));
ok( $("#first")[0], 'Replace element with set of elements' );
@@ -940,7 +961,7 @@ test("replaceAll(String|Element|Array<Element>|jQuery)", function() {
$('buga').replaceAll("#yahoo");
ok( $("#replace")[0], 'Replace element with string' );
ok( !$("#yahoo")[0], 'Verify that original element is gone, after string' );
-
+
reset();
$(document.getElementById('first')).replaceAll("#yahoo");
ok( $("#first")[0], 'Replace element with element' );
@@ -951,7 +972,7 @@ test("replaceAll(String|Element|Array<Element>|jQuery)", function() {
ok( $("#first")[0], 'Replace element with array of elements' );
ok( $("#mark")[0], 'Replace element with array of elements' );
ok( !$("#yahoo")[0], 'Verify that original element is gone, after array of elements' );
-
+
reset();
$("#first, #mark").replaceAll("#yahoo");
ok( $("#first")[0], 'Replace element with set of elements' );
@@ -963,7 +984,7 @@ test("end()", function() {
expect(3);
equals( 'Yahoo', $('#yahoo').parent().end().text(), 'Check for end' );
ok( $('#yahoo').end(), 'Check for end with nothing to end' );
-
+
var x = $('#yahoo');
x.parent();
equals( 'Yahoo', $('#yahoo').text(), 'Check for non-destructive behaviour' );
@@ -985,8 +1006,8 @@ test("clone()", function() {
equals( 'Try them out:Yahoo', $('#first').append(clone).text(), 'Check for clone' );
equals( 'This is a normal link: Yahoo', $('#en').text(), 'Reassert text for #en' );
- var cloneTags = [
- "
", "
", "
", "",
+ var cloneTags = [
+ "
", "
", "
", "",
"", "
", "", "",
"", "", "", "",
"", "", "", ""
@@ -1040,7 +1061,7 @@ test("is(String)", function() {
ok( !$('#foo').is(null), 'Expected false for an invalid expression - null' );
ok( !$('#foo').is(''), 'Expected false for an invalid expression - ""' );
ok( !$('#foo').is(undefined), 'Expected false for an invalid expression - undefined' );
-
+
// test is() with comma-seperated expressions
ok( $('#en').is('[lang="en"],[lang="de"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );
ok( $('#en').is('[lang="de"],[lang="en"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );
@@ -1073,17 +1094,17 @@ test("$.extend(Object, Object)", function() {
isObj( 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" );
equals( deep1.foo2, document, "Make sure that a deep clone was not attempted on the document" );
-
+
var nullUndef;
nullUndef = jQuery.extend({}, options, { xnumber2: null });
ok( nullUndef.xnumber2 === null, "Check to make sure null values are copied");
-
+
nullUndef = jQuery.extend({}, options, { xnumber2: undefined });
ok( nullUndef.xnumber2 === options.xnumber2, "Check to make sure undefined values are not copied");
-
+
nullUndef = jQuery.extend({}, options, { xnumber0: null });
ok( nullUndef.xnumber0 === null, "Check to make sure null values are inserted");
-
+
var target = {};
var recursive = { foo:target, bar:5 };
jQuery.extend(true, target, recursive);
@@ -1136,7 +1157,7 @@ test("val(String)", function() {
equals( $("#text1").val(), "bla", "Check for modified value of input element" );
$("#text1").val('test');
ok ( document.getElementById('text1').value == "test", "Check for modified (via val(String)) value of input element" );
-
+
$("#select1").val("3");
equals( $("#select1").val(), "3", "Check for modified (via val(String)) value of select element" );
@@ -1163,9 +1184,9 @@ test("html(String)", function() {
// using contents will get comments regular, text, and comment nodes
var j = $("#nonnodes").contents();
j.html("bold");
-
+
// this is needed, or the expando added by jQuery unique will yield a different html
- j.find('b').removeData();
+ j.find('b').removeData();
equals( j.html().toLowerCase(), "bold", "Check node,textnode,comment with html()" );
$("#main").html("");
@@ -1206,7 +1227,7 @@ test("not()", function() {
isSet( $("p").not($("#ap, #sndp, .result")).get(), q("firstp", "en", "sap", "first"), "not(jQuery)" );
equals( $("p").not(document.getElementsByTagName("p")).length, 0, "not(Array-like DOM collection)" );
isSet( $("#form option").not("option.emptyopt:contains('Nothing'),[selected],[value='1']").get(), q("option1c", "option1d", "option2c", "option3d" ), "not('complex selector')");
-
+
var selects = $("#form select");
isSet( selects.not( selects[1] ), q("select1", "select3"), "filter out DOM element");
});
@@ -1222,7 +1243,7 @@ test("andSelf()", function() {
test("siblings([String])", function() {
expect(5);
isSet( $("#en").siblings().get(), q("sndp", "sap"), "Check for siblings" );
- isSet( $("#sndp").siblings(":has(code)").get(), q("sap"), "Check for filtered siblings (has code child element)" );
+ isSet( $("#sndp").siblings(":has(code)").get(), q("sap"), "Check for filtered siblings (has code child element)" );
isSet( $("#sndp").siblings(":has(a)").get(), q("en", "sap"), "Check for filtered siblings (has anchor child element)" );
isSet( $("#foo").siblings("form, b").get(), q("form", "lengthtest", "testForm", "floatTest"), "Check for multiple filters" );
isSet( $("#en, #sndp").siblings().get(), q("sndp", "sap", "en"), "Check for unique results from siblings" );
@@ -1243,7 +1264,7 @@ test("parent([String])", function() {
equals( $("#groups").parent("div, p")[0].id, "ap", "Check for multiple filters" );
isSet( $("#en, #sndp").parent().get(), q("foo"), "Check for unique results from parent" );
});
-
+
test("parents([String])", function() {
expect(5);
equals( $("#groups").parents()[0].id, "ap", "Simple parents check" );
@@ -1260,7 +1281,7 @@ test("next([String])", function() {
equals( $("#ap").next("p").length, 0, "Filtered next check, no match" );
equals( $("#ap").next("div, p")[0].id, "foo", "Multiple filters" );
});
-
+
test("prev([String])", function() {
expect(4);
equals( $("#foo").prev()[0].id, "ap", "Simple prev check" );
@@ -1276,7 +1297,7 @@ test("show()", function() {
if ( this.style.display == "none" ) pass = false;
});
ok( pass, "Show" );
-
+
$("#main").append('
');
var test = {
"div" : "block",
@@ -1294,7 +1315,7 @@ test("show()", function() {
"ul" : "block",
"li" : $.browser.msie ? "block" : "list-item"
};
-
+
$.each(test, function(selector, expected) {
var elem = $(selector, "#show-tests").show();
equals( elem.css("display"), expected, "Show using correct display type for " + selector );
@@ -1325,7 +1346,7 @@ test("removeClass(String) - simple", function() {
if ( div.get(i).className.indexOf("test") != -1 ) pass = false;
}
ok( pass, "Remove Class" );
-
+
reset();
var div = $("div").addClass("test").addClass("foo").addClass("bar");
div.removeClass("test").removeClass("bar").removeClass("foo");
@@ -1334,11 +1355,11 @@ test("removeClass(String) - simple", function() {
if ( div.get(i).className.match(/test|bar|foo/) ) pass = false;
}
ok( pass, "Remove multiple classes" );
-
+
reset();
var div = $("div:eq(0)").addClass("test").removeClass("");
ok( div.is('.test'), "Empty string passed to removeClass" );
-
+
// using contents will get regular, text, and comment nodes
var j = $("#nonnodes").contents();
j.removeClass("asdf");
@@ -1350,7 +1371,7 @@ test("toggleClass(String)", function() {
var e = $("#firstp");
ok( !e.is(".test"), "Assert class not present" );
e.toggleClass("test");
- ok( e.is(".test"), "Assert class present" );
+ ok( e.is(".test"), "Assert class present" );
e.toggleClass("test");
ok( !e.is(".test"), "Assert class not present" );
});
@@ -1377,11 +1398,11 @@ test("$.each(Object,Function)", function() {
$.each( [0,1,2], function(i, n){
equals( i, n, "Check array iteration" );
});
-
+
$.each( [5,6,7], function(i, n){
equals( i, n - 5, "Check array iteration" );
});
-
+
$.each( { name: "name", lang: "lang" }, function(i, n){
equals( i, n, "Check object iteration" );
});
@@ -1450,10 +1471,10 @@ test(".data()", function() {
equals( div.data("test"), "overwritten", "Check that data wasn't removed");
div.data("test", null);
ok( div.data("test") === null, "Check for null data");
-
+
div.data("test", "overwritten");
var hits = {test:0}, gets = {test:0};
-
+
div
.bind("setData",function(e,key,value){ hits[key] += value; })
.bind("setData.foo",function(e,key,value){ hits[key] += value; })
@@ -1523,7 +1544,7 @@ test("remove()", function() {
$("#ap").children().remove();
ok( $("#ap").text().length > 10, "Check text is not removed" );
equals( $("#ap").children().length, 0, "Check remove" );
-
+
reset();
$("#ap").children().remove("a");
ok( $("#ap").text().length > 10, "Check text is not removed" );
@@ -1574,33 +1595,33 @@ test("map()", function() {
q("ap","ap","ap"),
"Single Map"
);
-
+
return;//these haven't been accepted yet
-
+
//for #2616
var keys = $.map( {a:1,b:2}, function( v, k ){
return k;
}, [ ] );
equals( keys.join(""), "ab", "Map the keys from a hash to an array" );
-
+
var values = $.map( {a:1,b:2}, function( v, k ){
return v;
}, [ ] );
equals( values.join(""), "12", "Map the values from a hash to an array" );
-
+
var scripts = document.getElementsByTagName("script");
var mapped = $.map( scripts, function( v, k ){
return v;
}, {length:0} );
equals( mapped.length, scripts.length, "Map an array(-like) to a hash" );
-
+
var flat = $.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)" );
});
@@ -1638,9 +1659,9 @@ test("contents()", function() {
test("$.makeArray", function(){
expect(15);
-
+
equals( $.makeArray($('html>*'))[0].nodeName, "HEAD", "Pass makeArray a jQuery object" );
-
+
equals( $.makeArray(document.getElementsByName("PWD")).slice(0,1)[0].name, "PWD", "Pass makeArray a nodelist" );
equals( (function(){ return $.makeArray(arguments); })(1,2).join(""), "12", "Pass makeArray an arguments array" );
@@ -1665,8 +1686,8 @@ test("$.makeArray", function(){
equals( $.makeArray( function(){ return 1;} )[0](), 1, "Pass makeArray a function" );
//window, also has length
equals( $.makeArray(window)[0], window, "Pass makeArray the window" );
-
+
equals( $.makeArray(/a/)[0].constructor, RegExp, "Pass makeArray a regex" );
-
+
ok( $.makeArray(document.getElementById('form')).length >= 13, "Pass makeArray a form (treat as elements)" );
});