if ( !isLocal ) {
-test("$.ajax() - success callbacks", function() {
+test("jQuery.ajax() - success callbacks", function() {
expect( 8 );
- $.ajaxSetup({ timeout: 0 });
+ jQuery.ajaxSetup({ timeout: 0 });
stop();
setTimeout(function(){
- $('#foo').ajaxStart(function(){
+ jQuery('#foo').ajaxStart(function(){
ok( true, "ajaxStart" );
}).ajaxStop(function(){
ok( true, "ajaxStop" );
ok( true, "ajaxSuccess" );
});
- $.ajax({
+ jQuery.ajax({
url: url("data/name.html"),
beforeSend: function(){ ok(true, "beforeSend"); },
success: function(){ ok(true, "success"); },
}, 13);
});
-test("$.ajax() - error callbacks", function() {
+test("jQuery.ajax() - error callbacks", function() {
expect( 8 );
stop();
- $('#foo').ajaxStart(function(){
+ jQuery('#foo').ajaxStart(function(){
ok( true, "ajaxStart" );
}).ajaxStop(function(){
ok( true, "ajaxStop" );
ok( false, "ajaxSuccess" );
});
- $.ajaxSetup({ timeout: 500 });
+ jQuery.ajaxSetup({ timeout: 500 });
- $.ajax({
+ jQuery.ajax({
url: url("data/name.php?wait=5"),
beforeSend: function(){ ok(true, "beforeSend"); },
success: function(){ ok(false, "success"); },
});
});
-test("$.ajax() - disabled globals", function() {
+test("jQuery.ajax() - disabled globals", function() {
expect( 3 );
stop();
- $('#foo').ajaxStart(function(){
+ jQuery('#foo').ajaxStart(function(){
ok( false, "ajaxStart" );
}).ajaxStop(function(){
ok( false, "ajaxStop" );
ok( false, "ajaxSuccess" );
});
- $.ajax({
+ jQuery.ajax({
global: false,
url: url("data/name.html"),
beforeSend: function(){ ok(true, "beforeSend"); },
});
});
-test("$.ajax - xml: non-namespace elements inside namespaced elements", function() {
+test("jQuery.ajax - xml: non-namespace elements inside namespaced elements", function() {
expect(3);
stop();
- $.ajax({
+ jQuery.ajax({
url: url("data/with_fries.xml"),
dataType: "xml",
success: function(resp) {
- equals( $("properties", resp).length, 1, 'properties in responseXML' );
- equals( $("jsconf", resp).length, 1, 'jsconf in responseXML' );
- equals( $("thing", resp).length, 2, 'things in responseXML' );
+ equals( jQuery("properties", resp).length, 1, 'properties in responseXML' );
+ equals( jQuery("jsconf", resp).length, 1, 'jsconf in responseXML' );
+ equals( jQuery("thing", resp).length, 2, 'things in responseXML' );
start();
}
});
});
-test("$.ajax - beforeSend", function() {
+test("jQuery.ajax - beforeSend", function() {
expect(1);
stop();
var check = false;
- $.ajaxSetup({ timeout: 0 });
+ jQuery.ajaxSetup({ timeout: 0 });
- $.ajax({
+ jQuery.ajax({
url: url("data/name.html"),
beforeSend: function(xml) {
check = true;
});
});
-test("$.ajax - beforeSend, cancel request (#2688)", function() {
+test("jQuery.ajax - beforeSend, cancel request (#2688)", function() {
expect(2);
- var request = $.ajax({
+ var request = jQuery.ajax({
url: url("data/name.html"),
beforeSend: function() {
ok( true, "beforeSend got called, canceling" );
var foobar;
-test("$.ajax - dataType html", function() {
+test("jQuery.ajax - dataType html", function() {
expect(5);
stop();
start();
};
- $.ajax({
+ jQuery.ajax({
dataType: "html",
url: url("data/test.html"),
success: function(data) {
- $("#ap").html(data);
+ jQuery("#ap").html(data);
ok( data.match(/^html text/), 'Check content for datatype html' );
setTimeout(verifyEvaluation, 600);
}
test("serialize()", function() {
expect(6);
- equals( $('#form').serialize(),
+ equals( jQuery('#form').serialize(),
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&select1=&select2=3&select3=1&select3=2",
'Check form serialization as query string');
- equals( $('#form :input').serialize(),
+ equals( jQuery('#form :input').serialize(),
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&select1=&select2=3&select3=1&select3=2",
'Check input serialization as query string');
- equals( $('#testForm').serialize(),
+ equals( jQuery('#testForm').serialize(),
'T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=',
'Check form serialization as query string');
- equals( $('#testForm :input').serialize(),
+ equals( jQuery('#testForm :input').serialize(),
'T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=',
'Check input serialization as query string');
- equals( $('#form, #testForm').serialize(),
+ equals( jQuery('#form, #testForm').serialize(),
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&select1=&select2=3&select3=1&select3=2&T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
'Multiple form serialization as query string');
- equals( $('#form, #testForm :input').serialize(),
+ equals( jQuery('#form, #testForm :input').serialize(),
"action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&select1=&select2=3&select3=1&select3=2&T3=%3F%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=",
'Mixed form/input serialization as query string');
});
-test("$.param()", function() {
+test("jQuery.param()", function() {
expect(4);
var params = {foo:"bar", baz:42, quux:"All your base are belong to us"};
- equals( $.param(params), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" );
+ equals( jQuery.param(params), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" );
params = {someName: [1, 2, 3], regularThing: "blah" };
- equals( $.param(params), "someName=1&someName=2&someName=3®ularThing=blah", "with array" );
+ equals( jQuery.param(params), "someName=1&someName=2&someName=3®ularThing=blah", "with array" );
params = {"foo[]":["baz", 42, "All your base are belong to us"]};
- equals( $.param(params), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" );
+ equals( jQuery.param(params), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" );
params = {"foo[bar]":"baz", "foo[beep]":42, "foo[quux]":"All your base are belong to us"};
- equals( $.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" );
+ equals( jQuery.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" );
});
test("synchronous request", function() {
expect(1);
- ok( /^{ "data"/.test( $.ajax({url: url("data/json_obj.js"), async: false}).responseText ), "check returned text" );
+ ok( /^{ "data"/.test( jQuery.ajax({url: url("data/json_obj.js"), async: false}).responseText ), "check returned text" );
});
test("synchronous request with callbacks", function() {
expect(2);
var result;
- $.ajax({url: url("data/json_obj.js"), async: false, success: function(data) { ok(true, "sucess callback executed"); result = data; } });
+ jQuery.ajax({url: url("data/json_obj.js"), async: false, success: function(data) { ok(true, "sucess callback executed"); result = data; } });
ok( /^{ "data"/.test( result ), "check returned text" );
});
var success = function() {
successCount++;
};
- $("#foo").ajaxError(function (e, xml, s, ex) {
+ jQuery("#foo").ajaxError(function (e, xml, s, ex) {
errorCount++;
errorEx += ": " + xml.status;
});
- $("#foo").one('ajaxStop', function () {
+ jQuery("#foo").one('ajaxStop', function () {
equals(successCount, 5, "Check all ajax calls successful");
equals(errorCount, 0, "Check no ajax errors (status" + errorEx + ")");
- $("#foo").unbind('ajaxError');
+ jQuery("#foo").unbind('ajaxError');
start();
});
- ok( $.get(url(target), success), "get" );
- ok( $.post(url(target), success), "post" );
- ok( $.getScript(url("data/test.js"), success), "script" );
- ok( $.getJSON(url("data/json_obj.js"), success), "json" );
- ok( $.ajax({url: url(target), success: success}), "generic" );
+ ok( jQuery.get(url(target), success), "get" );
+ ok( jQuery.post(url(target), success), "post" );
+ ok( jQuery.getScript(url("data/test.js"), success), "script" );
+ ok( jQuery.getJSON(url("data/json_obj.js"), success), "json" );
+ ok( jQuery.ajax({url: url(target), success: success}), "generic" );
});
test("ajax cache", function () {
var count = 0;
- $("#firstp").bind("ajaxSuccess", function (e, xml, s) {
+ jQuery("#firstp").bind("ajaxSuccess", function (e, xml, s) {
var re = /_=(.*?)(&|$)/g;
var oldOne = null;
for (var i = 0; i < 6; i++) {
start();
});
- ok( $.ajax({url: "data/text.php", cache:false}), "test with no parameters" );
- ok( $.ajax({url: "data/text.php?pizza=true", cache:false}), "test with 1 parameter" );
- ok( $.ajax({url: "data/text.php?_=tobereplaced555", cache:false}), "test with _= parameter" );
- ok( $.ajax({url: "data/text.php?pizza=true&_=tobereplaced555", cache:false}), "test with 1 parameter plus _= one" );
- ok( $.ajax({url: "data/text.php?_=tobereplaced555&tv=false", cache:false}), "test with 1 parameter plus _= one before it" );
- ok( $.ajax({url: "data/text.php?name=David&_=tobereplaced555&washere=true", cache:false}), "test with 2 parameters surrounding _= one" );
+ ok( jQuery.ajax({url: "data/text.php", cache:false}), "test with no parameters" );
+ ok( jQuery.ajax({url: "data/text.php?pizza=true", cache:false}), "test with 1 parameter" );
+ ok( jQuery.ajax({url: "data/text.php?_=tobereplaced555", cache:false}), "test with _= parameter" );
+ ok( jQuery.ajax({url: "data/text.php?pizza=true&_=tobereplaced555", cache:false}), "test with 1 parameter plus _= one" );
+ ok( jQuery.ajax({url: "data/text.php?_=tobereplaced555&tv=false", cache:false}), "test with 1 parameter plus _= one before it" );
+ ok( jQuery.ajax({url: "data/text.php?name=David&_=tobereplaced555&washere=true", cache:false}), "test with 2 parameters surrounding _= one" );
});
test("global ajaxSettings", function() {
var orig = { url: "data/with_fries.xml" };
var t;
- $.ajaxSetup({ data: {foo: 'bar', bar: 'BAR'} });
+ jQuery.ajaxSetup({ data: {foo: 'bar', bar: 'BAR'} });
t = jQuery.extend({}, orig);
t.data = {};
- $.ajax(t);
+ jQuery.ajax(t);
ok( t.url.indexOf('foo') > -1 && t.url.indexOf('bar') > -1, "Check extending {}" );
t = jQuery.extend({}, orig);
t.data = { zoo: 'a', ping: 'b' };
- $.ajax(t);
+ jQuery.ajax(t);
ok( t.url.indexOf('ping') > -1 && t.url.indexOf('zoo') > -1 && t.url.indexOf('foo') > -1 && t.url.indexOf('bar') > -1, "Check extending { zoo: 'a', ping: 'b' }" );
jQuery.ajaxSettings = tmp;
test("load(String)", function() {
expect(1);
stop(true); // check if load can be called with only url
- $('#first').load("data/name.html", start);
+ jQuery('#first').load("data/name.html", start);
});
test("load('url selector')", function() {
expect(1);
stop(true); // check if load can be called with only url
- $('#first').load("data/test3.html div.user", function(){
- equals( $(this).children("div").length, 2, "Verify that specific elements were injected" );
+ jQuery('#first').load("data/test3.html div.user", function(){
+ equals( jQuery(this).children("div").length, 2, "Verify that specific elements were injected" );
start();
});
});
test("load(String, Function) with ajaxSetup on dataType json, see #2046", function() {
expect(1);
stop();
- $.ajaxSetup({ dataType: "json" });
- $("#first").ajaxComplete(function (e, xml, s) {
+ jQuery.ajaxSetup({ dataType: "json" });
+ jQuery("#first").ajaxComplete(function (e, xml, s) {
equals( s.dataType, "html", "Verify the load() dataType was html" );
- $("#first").unbind("ajaxComplete");
- $.ajaxSetup({ dataType: "" });
+ jQuery("#first").unbind("ajaxComplete");
+ jQuery.ajaxSetup({ dataType: "" });
start();
});
- $('#first').load("data/test3.html");
+ jQuery('#first').load("data/test3.html");
});
test("load(String, Function) - simple: inject text into DOM", function() {
expect(2);
stop();
- $('#first').load(url("data/name.html"), function() {
- ok( /^ERROR/.test($('#first').text()), 'Check if content was injected into the DOM' );
+ jQuery('#first').load(url("data/name.html"), function() {
+ ok( /^ERROR/.test(jQuery('#first').text()), 'Check if content was injected into the DOM' );
start();
});
});
window.foobar = null;
var verifyEvaluation = function() {
equals( foobar, "bar", 'Check if script src was evaluated after load' );
- equals( $('#ap').html(), 'bar', 'Check if script evaluation has modified DOM');
+ equals( jQuery('#ap').html(), 'bar', 'Check if script evaluation has modified DOM');
start();
};
- $('#first').load(url('data/test.html'), function() {
- ok( $('#first').html().match(/^html text/), 'Check content after loading html' );
- equals( $('#foo').html(), 'foo', 'Check if script evaluation has modified DOM');
+ jQuery('#first').load(url('data/test.html'), function() {
+ ok( jQuery('#first').html().match(/^html text/), 'Check content after loading html' );
+ equals( jQuery('#foo').html(), 'foo', 'Check if script evaluation has modified DOM');
equals( testFoo, "foo", 'Check if script was evaluated after load' );
setTimeout(verifyEvaluation, 600);
});
expect(3);
stop();
testFoo = undefined;
- $('#first').load(url('data/test2.html'), function() {
- equals( $('#foo').html(), 'foo', 'Check if script evaluation has modified DOM');
+ jQuery('#first').load(url('data/test2.html'), function() {
+ equals( jQuery('#foo').html(), 'foo', 'Check if script evaluation has modified DOM');
equals( testFoo, "foo", 'Check if script was evaluated after load' );
start();
});
expect(2);
stop();
- $('<div />').load(url('data/params_html.php'), { foo:3, bar:'ok' }, function() {
- var $post = $(this).find('#post');
+ jQuery('<div />').load(url('data/params_html.php'), { foo:3, bar:'ok' }, function() {
+ var $post = jQuery(this).find('#post');
equals( $post.find('#foo').text(), '3', 'Check if a hash of data is passed correctly');
equals( $post.find('#bar').text(), 'ok', 'Check if a hash of data is passed correctly');
start();
expect(2);
stop();
- $('<div />').load(url('data/params_html.php'), 'foo=3&bar=ok', function() {
- var $get = $(this).find('#get');
+ jQuery('<div />').load(url('data/params_html.php'), 'foo=3&bar=ok', function() {
+ var $get = jQuery(this).find('#get');
equals( $get.find('#foo').text(), '3', 'Check if a string of data is passed correctly');
equals( $get.find('#bar').text(), 'ok', 'Check if a of data is passed correctly');
start();
});
});
-test("$.get(String, Hash, Function) - parse xml and use text() on nodes", function() {
+test("jQuery.get(String, Hash, Function) - parse xml and use text() on nodes", function() {
expect(2);
stop();
- $.get(url('data/dashboard.xml'), function(xml) {
+ jQuery.get(url('data/dashboard.xml'), function(xml) {
var content = [];
- $('tab', xml).each(function() {
- content.push($(this).text());
+ jQuery('tab', xml).each(function() {
+ content.push(jQuery(this).text());
});
equals( content[0], 'blabla', 'Check first tab');
equals( content[1], 'blublu', 'Check second tab');
});
});
-test("$.getScript(String, Function) - with callback", function() {
+test("jQuery.getScript(String, Function) - with callback", function() {
expect(2);
stop();
window.foobar = null;
- $.getScript(url("data/test.js"), function() {
+ jQuery.getScript(url("data/test.js"), function() {
equals( foobar, "bar", 'Check if script was evaluated' );
setTimeout(start, 100);
});
});
-test("$.getScript(String, Function) - no callback", function() {
+test("jQuery.getScript(String, Function) - no callback", function() {
expect(1);
stop(true);
- $.getScript(url("data/test.js"), start);
+ jQuery.getScript(url("data/test.js"), start);
});
-test("$.ajax() - JSONP, Local", function() {
+test("jQuery.ajax() - JSONP, Local", function() {
expect(7);
var count = 0;
stop();
- $.ajax({
+ jQuery.ajax({
url: "data/jsonp.php",
dataType: "jsonp",
success: function(data){
}
});
- $.ajax({
+ jQuery.ajax({
url: "data/jsonp.php?callback=?",
dataType: "jsonp",
success: function(data){
}
});
- $.ajax({
+ jQuery.ajax({
url: "data/jsonp.php",
dataType: "jsonp",
data: "callback=?",
}
});
- $.ajax({
+ jQuery.ajax({
url: "data/jsonp.php",
dataType: "jsonp",
jsonp: "callback",
}
});
- $.ajax({
+ jQuery.ajax({
type: "POST",
url: "data/jsonp.php",
dataType: "jsonp",
}
});
- $.ajax({
+ jQuery.ajax({
type: "POST",
url: "data/jsonp.php",
data: "callback=?",
}
});
- $.ajax({
+ jQuery.ajax({
type: "POST",
url: "data/jsonp.php",
jsonp: "callback",
});
});
-test("$.ajax() - JSONP, Remote", function() {
+test("jQuery.ajax() - JSONP, Remote", function() {
expect(4);
var count = 0;
stop();
- $.ajax({
+ jQuery.ajax({
url: base + "data/jsonp.php",
dataType: "jsonp",
success: function(data){
}
});
- $.ajax({
+ jQuery.ajax({
url: base + "data/jsonp.php?callback=?",
dataType: "jsonp",
success: function(data){
}
});
- $.ajax({
+ jQuery.ajax({
url: base + "data/jsonp.php",
dataType: "jsonp",
data: "callback=?",
}
});
- $.ajax({
+ jQuery.ajax({
url: base + "data/jsonp.php",
dataType: "jsonp",
jsonp: "callback",
});
});
-test("$.ajax() - script, Remote", function() {
+test("jQuery.ajax() - script, Remote", function() {
expect(2);
var base = window.location.href.replace(/\?.*$/, "");
stop();
window.foobar = null;
- $.ajax({
+ jQuery.ajax({
url: base + "data/test.js",
dataType: "script",
success: function(data){
});
});
-test("$.ajax() - script, Remote with POST", function() {
+test("jQuery.ajax() - script, Remote with POST", function() {
expect(3);
var base = window.location.href.replace(/\?.*$/, "");
stop();
window.foobar = null;
- $.ajax({
+ jQuery.ajax({
url: base + "data/test.js",
type: "POST",
dataType: "script",
});
});
-test("$.ajax() - script, Remote with scheme-less URL", function() {
+test("jQuery.ajax() - script, Remote with scheme-less URL", function() {
expect(2);
var base = window.location.href.replace(/\?.*$/, "");
stop();
window.foobar = null;
- $.ajax({
+ jQuery.ajax({
url: base + "data/test.js",
dataType: "script",
success: function(data){
});
});
-test("$.getJSON(String, Hash, Function) - JSON array", function() {
+test("jQuery.getJSON(String, Hash, Function) - JSON array", function() {
expect(4);
stop();
- $.getJSON(url("data/json.php"), {json: "array"}, function(json) {
+ jQuery.getJSON(url("data/json.php"), {json: "array"}, function(json) {
equals( json[0].name, 'John', 'Check JSON: first, name' );
equals( json[0].age, 21, 'Check JSON: first, age' );
equals( json[1].name, 'Peter', 'Check JSON: second, name' );
});
});
-test("$.getJSON(String, Function) - JSON object", function() {
+test("jQuery.getJSON(String, Function) - JSON object", function() {
expect(2);
stop();
- $.getJSON(url("data/json.php"), function(json) {
+ jQuery.getJSON(url("data/json.php"), function(json) {
equals( json.data.lang, 'en', 'Check JSON: lang' );
equals( json.data.length, 25, 'Check JSON: length' );
start();
});
});
-test("$.getJSON(String, Function) - JSON object with absolute url to local content", function() {
+test("jQuery.getJSON(String, Function) - JSON object with absolute url to local content", function() {
expect(2);
var base = window.location.href.replace(/\?.*$/, "");
stop();
- $.getJSON(url(base + "data/json.php"), function(json) {
+ jQuery.getJSON(url(base + "data/json.php"), function(json) {
equals( json.data.lang, 'en', 'Check JSON: lang' );
equals( json.data.length, 25, 'Check JSON: length' );
start();
});
});
-test("$.post(String, Hash, Function) - simple with xml", function() {
+test("jQuery.post(String, Hash, Function) - simple with xml", function() {
expect(4);
stop();
- $.post(url("data/name.php"), {xml: "5-2"}, function(xml){
- $('math', xml).each(function() {
- equals( $('calculation', this).text(), '5-2', 'Check for XML' );
- equals( $('result', this).text(), '3', 'Check for XML' );
+ jQuery.post(url("data/name.php"), {xml: "5-2"}, function(xml){
+ jQuery('math', xml).each(function() {
+ equals( jQuery('calculation', this).text(), '5-2', 'Check for XML' );
+ equals( jQuery('result', this).text(), '3', 'Check for XML' );
});
});
- $.post(url("data/name.php?xml=5-2"), {}, function(xml){
- $('math', xml).each(function() {
- equals( $('calculation', this).text(), '5-2', 'Check for XML' );
- equals( $('result', this).text(), '3', 'Check for XML' );
+ jQuery.post(url("data/name.php?xml=5-2"), {}, function(xml){
+ jQuery('math', xml).each(function() {
+ equals( jQuery('calculation', this).text(), '5-2', 'Check for XML' );
+ equals( jQuery('result', this).text(), '3', 'Check for XML' );
});
start();
});
});
-test("$.ajaxSetup({timeout: Number}) - with global timeout", function() {
+test("jQuery.ajaxSetup({timeout: Number}) - with global timeout", function() {
stop();
var passed = 0;
- $.ajaxSetup({timeout: 1000});
+ jQuery.ajaxSetup({timeout: 1000});
var pass = function() {
passed++;
if ( passed == 2 ) {
ok( true, 'Check local and global callbacks after timeout' );
- $('#main').unbind("ajaxError");
+ jQuery('#main').unbind("ajaxError");
start();
}
};
start();
};
- $('#main').ajaxError(pass);
+ jQuery('#main').ajaxError(pass);
- $.ajax({
+ jQuery.ajax({
type: "GET",
url: url("data/name.php?wait=5"),
error: pass,
});
// reset timeout
- $.ajaxSetup({timeout: 0});
+ jQuery.ajaxSetup({timeout: 0});
});
-test("$.ajaxSetup({timeout: Number}) with localtimeout", function() {
+test("jQuery.ajaxSetup({timeout: Number}) with localtimeout", function() {
stop();
- $.ajaxSetup({timeout: 50});
+ jQuery.ajaxSetup({timeout: 50});
- $.ajax({
+ jQuery.ajax({
type: "GET",
timeout: 5000,
url: url("data/name.php?wait=1"),
});
// reset timeout
- $.ajaxSetup({timeout: 0});
+ jQuery.ajaxSetup({timeout: 0});
});
-test("$.ajax - simple get", function() {
+test("jQuery.ajax - simple get", function() {
expect(1);
stop();
- $.ajax({
+ jQuery.ajax({
type: "GET",
url: url("data/name.php?name=foo"),
success: function(msg){
});
});
-test("$.ajax - simple post", function() {
+test("jQuery.ajax - simple post", function() {
expect(1);
stop();
- $.ajax({
+ jQuery.ajax({
type: "POST",
url: url("data/name.php"),
data: "name=peter",
test("ajaxSetup()", function() {
expect(1);
stop();
- $.ajaxSetup({
+ jQuery.ajaxSetup({
url: url("data/name.php?name=foo"),
success: function(msg){
equals( msg, 'bar', 'Check for GET' );
start();
}
});
- $.ajax();
+ jQuery.ajax();
});
test("custom timeout does not set error message when timeout occurs, see #970", function() {
stop();
- $.ajax({
+ jQuery.ajax({
url: "data/name.php?wait=10",
timeout: 500,
error: function(request, status) {
test("data option: evaluate function values (#2806)", function() {
stop();
- $.ajax({
+ jQuery.ajax({
url: "data/echoQuery.php",
data: {
key: function() {
ok( document.getElementsByTagName, "getElementsByTagName" );\r
ok( RegExp, "RegExp" );\r
ok( jQuery, "jQuery" );\r
- ok( $, "$()" );\r
+ ok( $, "$" );\r
});\r
\r
-test("$()", function() {\r
+test("jQuery()", function() {\r
expect(8);\r
\r
- var main = $("#main");\r
- isSet( $("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" );\r
+ var main = jQuery("#main");\r
+ isSet( jQuery("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" );\r
\r
/*\r
// disabled since this test was doing nothing. i tried to fix it but i'm not sure\r
// what the expected behavior should even be. FF returns "\n" for the text node\r
// make sure this is handled\r
- var crlfContainer = $('<p>\r\n</p>');\r
+ var crlfContainer = jQuery('<p>\r\n</p>');\r
var x = crlfContainer.contents().get(0).nodeValue;\r
equals( x, what???, "Check for \\r and \\n in jQuery()" );\r
*/\r
/* // Disabled until we add this functionality in\r
var pass = true;\r
try {\r
- $("<div>Testing</div>").appendTo(document.getElementById("iframe").contentDocument.body);\r
+ jQuery("<div>Testing</div>").appendTo(document.getElementById("iframe").contentDocument.body);\r
} catch(e){\r
pass = false;\r
}\r
- ok( pass, "$('<tag>') needs optional document parameter to ease cross-frame DOM wrangling, see #968" );*/\r
+ ok( pass, "jQuery('<tag>') needs optional document parameter to ease cross-frame DOM wrangling, see #968" );*/\r
\r
- var code = $("<code/>");\r
+ var code = jQuery("<code/>");\r
equals( code.length, 1, "Correct number of elements generated for code" );\r
- var img = $("<img/>");\r
+ var img = jQuery("<img/>");\r
equals( img.length, 1, "Correct number of elements generated for img" );\r
- var div = $("<div/><hr/><code/><b/>");\r
+ var div = jQuery("<div/><hr/><code/><b/>");\r
equals( div.length, 4, "Correct number of elements generated for div hr code b" );\r
\r
// can actually yield more than one, when iframes are included, the window is an array as well\r
- equals( $(window).length, 1, "Correct number of elements generated for window" );\r
+ equals( jQuery(window).length, 1, "Correct number of elements generated for window" );\r
\r
- equals( $(document).length, 1, "Correct number of elements generated for document" );\r
+ equals( jQuery(document).length, 1, "Correct number of elements generated for document" );\r
\r
- equals( $([1,2,3]).get(1), 2, "Test passing an array to the factory" );\r
+ equals( jQuery([1,2,3]).get(1), 2, "Test passing an array to the factory" );\r
\r
- equals( $(document.body).get(0), $('body').get(0), "Test passing an html node to the factory" );\r
+ equals( jQuery(document.body).get(0), jQuery('body').get(0), "Test passing an html node to the factory" );\r
});\r
\r
test("browser", function() {\r
test("noConflict", function() {\r
expect(6);\r
\r
- var old = jQuery;\r
- var newjQuery = jQuery.noConflict();\r
+ var $$ = jQuery;\r
\r
- equals( newjQuery, old, "noConflict returned the jQuery object" );\r
- equals( jQuery, old, "Make sure jQuery wasn't touched." );\r
- equals( $, "$", "Make sure $ was reverted." );\r
+ equals( jQuery, jQuery.noConflict(), "noConflict returned the jQuery object" );\r
+ equals( jQuery, $$, "Make sure jQuery wasn't touched." );\r
+ equals( $, original$, "Make sure $ was reverted." );\r
\r
- jQuery = $ = old;\r
+ jQuery = $ = $$;\r
\r
- newjQuery = jQuery.noConflict(true);\r
+ equals( jQuery.noConflict(true), $$, "noConflict returned the jQuery object" );\r
+ equals( jQuery, originaljQuery, "Make sure jQuery was reverted." );\r
+ equals( $, original$, "Make sure $ was reverted." );\r
\r
- equals( newjQuery, old, "noConflict returned the jQuery object" );\r
- equals( jQuery, "jQuery", "Make sure jQuery was reverted." );\r
- equals( $, "$", "Make sure $ was reverted." );\r
-\r
- jQuery = $ = old;\r
+ jQuery = $$;\r
});\r
\r
test("isFunction", function() {\r
\r
var foo = false;\r
\r
-test("$('html')", function() {\r
+test("jQuery('html')", function() {\r
expect(6);\r
\r
reset();\r
foo = false;\r
- var s = $("<script>var foo='test';</script>")[0];\r
+ var s = jQuery("<script>var foo='test';</script>")[0];\r
ok( s, "Creating a script" );\r
ok( !foo, "Make sure the script wasn't executed prematurely" );\r
- $("body").append(s);\r
+ jQuery("body").append(s);\r
ok( foo, "Executing a scripts contents in the right context" );\r
\r
reset();\r
- ok( $("<link rel='stylesheet'/>")[0], "Creating a link" );\r
+ ok( jQuery("<link rel='stylesheet'/>")[0], "Creating a link" );\r
\r
reset();\r
\r
- var j = $("<span>hi</span> there <!-- mon ami -->");\r
+ var j = jQuery("<span>hi</span> there <!-- mon ami -->");\r
ok( j.length >= 2, "Check node,textnode,comment creation (some browsers delete comments)" );\r
\r
- ok( !$("<option>test</option>")[0].selected, "Make sure that options are auto-selected #2050" );\r
+ ok( !jQuery("<option>test</option>")[0].selected, "Make sure that options are auto-selected #2050" );\r
});\r
\r
-test("$('html', context)", function() {\r
+test("jQuery('html', context)", function() {\r
expect(1);\r
\r
- var $div = $("<div/>");\r
- var $span = $("<span/>", $div);\r
+ var $div = jQuery("<div/>");\r
+ var $span = jQuery("<span/>", $div);\r
equals($span.length, 1, "Verify a span created with a div context works, #1763");\r
});\r
\r
if ( !isLocal ) {\r
-test("$(selector, xml).text(str) - Loaded via XML document", function() {\r
+test("jQuery(selector, xml).text(str) - Loaded via XML document", function() {\r
expect(2);\r
stop();\r
- $.get('data/dashboard.xml', function(xml) {\r
+ jQuery.get('data/dashboard.xml', function(xml) {\r
// tests for #1419 where IE was a problem\r
- equals( $("tab:first", xml).text(), "blabla", "Verify initial text correct" );\r
- $("tab:first", xml).text("newtext");\r
- equals( $("tab:first", xml).text(), "newtext", "Verify new text correct" );\r
+ equals( jQuery("tab:first", xml).text(), "blabla", "Verify initial text correct" );\r
+ jQuery("tab:first", xml).text("newtext");\r
+ equals( jQuery("tab:first", xml).text(), "newtext", "Verify new text correct" );\r
start();\r
});\r
});\r
\r
test("length", function() {\r
expect(1);\r
- equals( $("p").length, 6, "Get Number of Elements Found" );\r
+ equals( jQuery("p").length, 6, "Get Number of Elements Found" );\r
});\r
\r
test("size()", function() {\r
expect(1);\r
- equals( $("p").size(), 6, "Get Number of Elements Found" );\r
+ equals( jQuery("p").size(), 6, "Get Number of Elements Found" );\r
});\r
\r
test("get()", function() {\r
expect(1);\r
- isSet( $("p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" );\r
+ isSet( jQuery("p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" );\r
});\r
\r
test("get(Number)", function() {\r
expect(1);\r
- equals( $("p").get(0), document.getElementById("firstp"), "Get A Single Element" );\r
+ equals( jQuery("p").get(0), document.getElementById("firstp"), "Get A Single Element" );\r
});\r
\r
test("add(String|Element|Array|undefined)", function() {\r
expect(12);\r
- isSet( $("#sndp").add("#en").add("#sap").get(), q("sndp", "en", "sap"), "Check elements from document" );\r
- isSet( $("#sndp").add( $("#en")[0] ).add( $("#sap") ).get(), q("sndp", "en", "sap"), "Check elements from document" );\r
- ok( $([]).add($("#form")[0].elements).length >= 13, "Check elements from array" );\r
+ isSet( jQuery("#sndp").add("#en").add("#sap").get(), q("sndp", "en", "sap"), "Check elements from document" );\r
+ isSet( jQuery("#sndp").add( jQuery("#en")[0] ).add( jQuery("#sap") ).get(), q("sndp", "en", "sap"), "Check elements from document" );\r
+ ok( jQuery([]).add(jQuery("#form")[0].elements).length >= 13, "Check elements from array" );\r
\r
- // For the time being, we're discontinuing support for $(form.elements) since it's ambiguous in IE\r
- // use $([]).add(form.elements) instead.\r
- //equals( $([]).add($("#form")[0].elements).length, $($("#form")[0].elements).length, "Array in constructor must equals array in add()" );\r
+ // For the time being, we're discontinuing support for jQuery(form.elements) since it's ambiguous in IE\r
+ // use jQuery([]).add(form.elements) instead.\r
+ //equals( jQuery([]).add(jQuery("#form")[0].elements).length, jQuery(jQuery("#form")[0].elements).length, "Array in constructor must equals array in add()" );\r
\r
- var x = $([]).add($("<p id='x1'>xxx</p>")).add($("<p id='x2'>xxx</p>"));\r
+ var x = jQuery([]).add(jQuery("<p id='x1'>xxx</p>")).add(jQuery("<p id='x2'>xxx</p>"));\r
equals( x[0].id, "x1", "Check on-the-fly element1" );\r
equals( x[1].id, "x2", "Check on-the-fly element2" );\r
\r
- var x = $([]).add("<p id='x1'>xxx</p>").add("<p id='x2'>xxx</p>");\r
+ var x = jQuery([]).add("<p id='x1'>xxx</p>").add("<p id='x2'>xxx</p>");\r
equals( x[0].id, "x1", "Check on-the-fly element1" );\r
equals( x[1].id, "x2", "Check on-the-fly element2" );\r
\r
var notDefined;\r
- equals( $([]).add(notDefined).length, 0, "Check that undefined adds nothing" );\r
+ equals( jQuery([]).add(notDefined).length, 0, "Check that undefined adds nothing" );\r
\r
// Added after #2811\r
- equals( $([]).add([window,document,document.body,document]).length, 3, "Pass an array" );\r
- equals( $(document).add(document).length, 1, "Check duplicated elements" );\r
- equals( $(window).add(window).length, 1, "Check duplicated elements using the window" );\r
- ok( $([]).add( document.getElementById('form') ).length >= 13, "Add a form (adds the elements)" );\r
+ equals( jQuery([]).add([window,document,document.body,document]).length, 3, "Pass an array" );\r
+ equals( jQuery(document).add(document).length, 1, "Check duplicated elements" );\r
+ equals( jQuery(window).add(window).length, 1, "Check duplicated elements using the window" );\r
+ ok( jQuery([]).add( document.getElementById('form') ).length >= 13, "Add a form (adds the elements)" );\r
});\r
\r
test("each(Function)", function() {\r
expect(1);\r
- var div = $("div");\r
+ var div = jQuery("div");\r
div.each(function(){this.foo = 'zoo';});\r
var pass = true;\r
for ( var i = 0; i < div.size(); i++ ) {\r
test("index(Object)", function() {\r
expect(10);\r
\r
- var elements = $([window, document]),\r
- inputElements = $('#radio1,#radio2,#check1,#check2');\r
+ var elements = jQuery([window, document]),\r
+ inputElements = jQuery('#radio1,#radio2,#check1,#check2');\r
\r
equals( elements.index(window), 0, "Check for index of elements" );\r
equals( elements.index(document), 1, "Check for index of elements" );\r
\r
test("attr(String)", function() {\r
expect(26);\r
- equals( $('#text1').attr('value'), "Test", 'Check for value attribute' );\r
- equals( $('#text1').attr('value', "Test2").attr('defaultValue'), "Test", 'Check for defaultValue attribute' );\r
- equals( $('#text1').attr('type'), "text", 'Check for type attribute' );\r
- equals( $('#radio1').attr('type'), "radio", 'Check for type attribute' );\r
- equals( $('#check1').attr('type'), "checkbox", 'Check for type attribute' );\r
- equals( $('#simon1').attr('rel'), "bookmark", 'Check for rel attribute' );\r
- equals( $('#google').attr('title'), "Google!", 'Check for title attribute' );\r
- equals( $('#mark').attr('hreflang'), "en", 'Check for hreflang attribute' );\r
- equals( $('#en').attr('lang'), "en", 'Check for lang attribute' );\r
- equals( $('#simon').attr('class'), "blog link", 'Check for class attribute' );\r
- equals( $('#name').attr('name'), "name", 'Check for name attribute' );\r
- equals( $('#text1').attr('name'), "action", 'Check for name attribute' );\r
- ok( $('#form').attr('action').indexOf("formaction") >= 0, 'Check for action attribute' );\r
- equals( $('#text1').attr('maxlength'), '30', 'Check for maxlength attribute' );\r
- equals( $('#text1').attr('maxLength'), '30', 'Check for maxLength attribute' );\r
- equals( $('#area1').attr('maxLength'), '30', 'Check for maxLength attribute' );\r
- equals( $('#select2').attr('selectedIndex'), 3, 'Check for selectedIndex attribute' );\r
- equals( $('#foo').attr('nodeName'), 'DIV', 'Check for nodeName attribute' );\r
- equals( $('#foo').attr('tagName'), 'DIV', 'Check for tagName attribute' );\r
-\r
- $('<a id="tAnchor5"></a>').attr('href', '#5').appendTo('#main'); // using innerHTML in IE causes href attribute to be serialized to the full path\r
- equals( $('#tAnchor5').attr('href'), "#5", 'Check for non-absolute href (an anchor)' );\r
+ equals( jQuery('#text1').attr('value'), "Test", 'Check for value attribute' );\r
+ equals( jQuery('#text1').attr('value', "Test2").attr('defaultValue'), "Test", 'Check for defaultValue attribute' );\r
+ equals( jQuery('#text1').attr('type'), "text", 'Check for type attribute' );\r
+ equals( jQuery('#radio1').attr('type'), "radio", 'Check for type attribute' );\r
+ equals( jQuery('#check1').attr('type'), "checkbox", 'Check for type attribute' );\r
+ equals( jQuery('#simon1').attr('rel'), "bookmark", 'Check for rel attribute' );\r
+ equals( jQuery('#google').attr('title'), "Google!", 'Check for title attribute' );\r
+ equals( jQuery('#mark').attr('hreflang'), "en", 'Check for hreflang attribute' );\r
+ equals( jQuery('#en').attr('lang'), "en", 'Check for lang attribute' );\r
+ equals( jQuery('#simon').attr('class'), "blog link", 'Check for class attribute' );\r
+ equals( jQuery('#name').attr('name'), "name", 'Check for name attribute' );\r
+ equals( jQuery('#text1').attr('name'), "action", 'Check for name attribute' );\r
+ ok( jQuery('#form').attr('action').indexOf("formaction") >= 0, 'Check for action attribute' );\r
+ equals( jQuery('#text1').attr('maxlength'), '30', 'Check for maxlength attribute' );\r
+ equals( jQuery('#text1').attr('maxLength'), '30', 'Check for maxLength attribute' );\r
+ equals( jQuery('#area1').attr('maxLength'), '30', 'Check for maxLength attribute' );\r
+ equals( jQuery('#select2').attr('selectedIndex'), 3, 'Check for selectedIndex attribute' );\r
+ equals( jQuery('#foo').attr('nodeName'), 'DIV', 'Check for nodeName attribute' );\r
+ equals( jQuery('#foo').attr('tagName'), 'DIV', 'Check for tagName attribute' );\r
+\r
+ jQuery('<a id="tAnchor5"></a>').attr('href', '#5').appendTo('#main'); // using innerHTML in IE causes href attribute to be serialized to the full path\r
+ equals( jQuery('#tAnchor5').attr('href'), "#5", 'Check for non-absolute href (an anchor)' );\r
\r
\r
// Related to [5574] and [5683]\r
- var body = document.body, $body = $(body);\r
+ var body = document.body, $body = jQuery(body);\r
\r
ok( $body.attr('foo') === undefined, 'Make sure that a non existent attribute returns undefined' );\r
ok( $body.attr('nextSibling') === null, 'Make sure a null expando returns null' );\r
test("attr(String) in XML Files", function() {\r
expect(2);\r
stop();\r
- $.get("data/dashboard.xml", function(xml) {\r
- equals( $("locations", xml).attr("class"), "foo", "Check class attribute in XML document" );\r
- equals( $("location", xml).attr("for"), "bar", "Check for attribute in XML document" );\r
+ jQuery.get("data/dashboard.xml", function(xml) {\r
+ equals( jQuery("locations", xml).attr("class"), "foo", "Check class attribute in XML document" );\r
+ equals( jQuery("location", xml).attr("for"), "bar", "Check for attribute in XML document" );\r
start();\r
});\r
});\r
\r
test("attr(String, Function)", function() {\r
expect(2);\r
- equals( $('#text1').attr('value', function() { return this.id })[0].value, "text1", "Set value from id" );\r
- equals( $('#text1').attr('title', function(i) { return i }).attr('title'), "0", "Set value with an index");\r
+ equals( jQuery('#text1').attr('value', function() { return this.id })[0].value, "text1", "Set value from id" );\r
+ equals( jQuery('#text1').attr('title', function(i) { return i }).attr('title'), "0", "Set value with an index");\r
});\r
\r
test("attr(Hash)", function() {\r
expect(1);\r
var pass = true;\r
- $("div").attr({foo: 'baz', zoo: 'ping'}).each(function(){\r
+ jQuery("div").attr({foo: 'baz', zoo: 'ping'}).each(function(){\r
if ( this.getAttribute('foo') != "baz" && this.getAttribute('zoo') != "ping" ) pass = false;\r
});\r
ok( pass, "Set Multiple Attributes" );\r
\r
test("attr(String, Object)", function() {\r
expect(17);\r
- var div = $("div").attr("foo", "bar");\r
+ var div = jQuery("div").attr("foo", "bar");\r
fail = false;\r
for ( var i = 0; i < div.size(); i++ ) {\r
if ( div.get(i).getAttribute('foo') != "bar" ){\r
}\r
equals( fail, false, "Set Attribute, the #"+fail+" element didn't get the attribute 'foo'" );\r
\r
- ok( $("#foo").attr({"width": null}), "Try to set an attribute to nothing" );\r
+ ok( jQuery("#foo").attr({"width": null}), "Try to set an attribute to nothing" );\r
\r
- $("#name").attr('name', 'something');\r
- equals( $("#name").attr('name'), 'something', 'Set name attribute' );\r
- $("#check2").attr('checked', true);\r
+ jQuery("#name").attr('name', 'something');\r
+ equals( jQuery("#name").attr('name'), 'something', 'Set name attribute' );\r
+ jQuery("#check2").attr('checked', true);\r
equals( document.getElementById('check2').checked, true, 'Set checked attribute' );\r
- $("#check2").attr('checked', false);\r
+ jQuery("#check2").attr('checked', false);\r
equals( document.getElementById('check2').checked, false, 'Set checked attribute' );\r
- $("#text1").attr('readonly', true);\r
+ jQuery("#text1").attr('readonly', true);\r
equals( document.getElementById('text1').readOnly, true, 'Set readonly attribute' );\r
- $("#text1").attr('readonly', false);\r
+ jQuery("#text1").attr('readonly', false);\r
equals( document.getElementById('text1').readOnly, false, 'Set readonly attribute' );\r
- $("#name").attr('maxlength', '5');\r
+ jQuery("#name").attr('maxlength', '5');\r
equals( document.getElementById('name').maxLength, '5', 'Set maxlength attribute' );\r
- $("#name").attr('maxLength', '10');\r
+ jQuery("#name").attr('maxLength', '10');\r
equals( document.getElementById('name').maxLength, '10', 'Set maxlength attribute' );\r
\r
// for #1070\r
- $("#name").attr('someAttr', '0');\r
- equals( $("#name").attr('someAttr'), '0', 'Set attribute to a string of "0"' );\r
- $("#name").attr('someAttr', 0);\r
- equals( $("#name").attr('someAttr'), 0, 'Set attribute to the number 0' );\r
- $("#name").attr('someAttr', 1);\r
- equals( $("#name").attr('someAttr'), 1, 'Set attribute to the number 1' );\r
+ jQuery("#name").attr('someAttr', '0');\r
+ equals( jQuery("#name").attr('someAttr'), '0', 'Set attribute to a string of "0"' );\r
+ jQuery("#name").attr('someAttr', 0);\r
+ equals( jQuery("#name").attr('someAttr'), 0, 'Set attribute to the number 0' );\r
+ jQuery("#name").attr('someAttr', 1);\r
+ equals( jQuery("#name").attr('someAttr'), 1, 'Set attribute to the number 1' );\r
\r
// using contents will get comments regular, text, and comment nodes\r
- var j = $("#nonnodes").contents();\r
+ var j = jQuery("#nonnodes").contents();\r
\r
j.attr("name", "attrvalue");\r
equals( j.attr("name"), "attrvalue", "Check node,textnode,comment for attr" );\r
\r
reset();\r
\r
- var type = $("#check2").attr('type');\r
+ var type = jQuery("#check2").attr('type');\r
var thrown = false;\r
try {\r
- $("#check2").attr('type','hidden');\r
+ jQuery("#check2").attr('type','hidden');\r
} catch(e) {\r
thrown = true;\r
}\r
ok( thrown, "Exception thrown when trying to change type property" );\r
- equals( type, $("#check2").attr('type'), "Verify that you can't change the type of an input element" );\r
+ equals( type, jQuery("#check2").attr('type'), "Verify that you can't change the type of an input element" );\r
\r
var check = document.createElement("input");\r
var thrown = true;\r
try {\r
- $(check).attr('type','checkbox');\r
+ jQuery(check).attr('type','checkbox');\r
} catch(e) {\r
thrown = false;\r
}\r
ok( thrown, "Exception thrown when trying to change type property" );\r
- equals( "checkbox", $(check).attr('type'), "Verify that you can change the type of an input element that isn't in the DOM" );\r
+ equals( "checkbox", jQuery(check).attr('type'), "Verify that you can change the type of an input element that isn't in the DOM" );\r
});\r
\r
if ( !isLocal ) {\r
test("attr(String, Object) - Loaded via XML document", function() {\r
expect(2);\r
stop();\r
- $.get('data/dashboard.xml', function(xml) {\r
+ jQuery.get('data/dashboard.xml', function(xml) {\r
var titles = [];\r
- $('tab', xml).each(function() {\r
- titles.push($(this).attr('title'));\r
+ jQuery('tab', xml).each(function() {\r
+ titles.push(jQuery(this).attr('title'));\r
});\r
equals( titles[0], 'Location', 'attr() in XML context: Check first title' );\r
equals( titles[1], 'Users', 'attr() in XML context: Check second title' );\r
test("css(String|Hash)", function() {\r
expect(19);\r
\r
- equals( $('#main').css("display"), 'none', 'Check for css property "display"');\r
-\r
- ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible');\r
- $('#foo').css({display: 'none'});\r
- ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');\r
- $('#foo').css({display: 'block'});\r
- ok( $('#foo').is(':visible'), 'Modified CSS display: Assert element is visible');\r
-\r
- $('#floatTest').css({styleFloat: 'right'});\r
- equals( $('#floatTest').css('styleFloat'), 'right', 'Modified CSS float using "styleFloat": Assert float is right');\r
- $('#floatTest').css({cssFloat: 'left'});\r
- equals( $('#floatTest').css('cssFloat'), 'left', 'Modified CSS float using "cssFloat": Assert float is left');\r
- $('#floatTest').css({'float': 'right'});\r
- equals( $('#floatTest').css('float'), 'right', 'Modified CSS float using "float": Assert float is right');\r
- $('#floatTest').css({'font-size': '30px'});\r
- equals( $('#floatTest').css('font-size'), '30px', 'Modified CSS font-size: Assert font-size is 30px');\r
-\r
- $.each("0,0.25,0.5,0.75,1".split(','), function(i, n) {\r
- $('#foo').css({opacity: n});\r
- equals( $('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );\r
- $('#foo').css({opacity: parseFloat(n)});\r
- equals( $('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );\r
+ equals( jQuery('#main').css("display"), 'none', 'Check for css property "display"');\r
+\r
+ ok( jQuery('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible');\r
+ jQuery('#foo').css({display: 'none'});\r
+ ok( !jQuery('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');\r
+ jQuery('#foo').css({display: 'block'});\r
+ ok( jQuery('#foo').is(':visible'), 'Modified CSS display: Assert element is visible');\r
+\r
+ jQuery('#floatTest').css({styleFloat: 'right'});\r
+ equals( jQuery('#floatTest').css('styleFloat'), 'right', 'Modified CSS float using "styleFloat": Assert float is right');\r
+ jQuery('#floatTest').css({cssFloat: 'left'});\r
+ equals( jQuery('#floatTest').css('cssFloat'), 'left', 'Modified CSS float using "cssFloat": Assert float is left');\r
+ jQuery('#floatTest').css({'float': 'right'});\r
+ equals( jQuery('#floatTest').css('float'), 'right', 'Modified CSS float using "float": Assert float is right');\r
+ jQuery('#floatTest').css({'font-size': '30px'});\r
+ equals( jQuery('#floatTest').css('font-size'), '30px', 'Modified CSS font-size: Assert font-size is 30px');\r
+\r
+ jQuery.each("0,0.25,0.5,0.75,1".split(','), function(i, n) {\r
+ jQuery('#foo').css({opacity: n});\r
+ equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );\r
+ jQuery('#foo').css({opacity: parseFloat(n)});\r
+ equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );\r
});\r
- $('#foo').css({opacity: ''});\r
- equals( $('#foo').css('opacity'), '1', "Assert opacity is 1 when set to an empty String" );\r
+ jQuery('#foo').css({opacity: ''});\r
+ equals( jQuery('#foo').css('opacity'), '1', "Assert opacity is 1 when set to an empty String" );\r
});\r
\r
test("css(String, Object)", function() {\r
expect(21);\r
- ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible');\r
- $('#foo').css('display', 'none');\r
- ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');\r
- $('#foo').css('display', 'block');\r
- ok( $('#foo').is(':visible'), 'Modified CSS display: Assert element is visible');\r
-\r
- $('#floatTest').css('styleFloat', 'left');\r
- equals( $('#floatTest').css('styleFloat'), 'left', 'Modified CSS float using "styleFloat": Assert float is left');\r
- $('#floatTest').css('cssFloat', 'right');\r
- equals( $('#floatTest').css('cssFloat'), 'right', 'Modified CSS float using "cssFloat": Assert float is right');\r
- $('#floatTest').css('float', 'left');\r
- equals( $('#floatTest').css('float'), 'left', 'Modified CSS float using "float": Assert float is left');\r
- $('#floatTest').css('font-size', '20px');\r
- equals( $('#floatTest').css('font-size'), '20px', 'Modified CSS font-size: Assert font-size is 20px');\r
-\r
- $.each("0,0.25,0.5,0.75,1".split(','), function(i, n) {\r
- $('#foo').css('opacity', n);\r
- equals( $('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );\r
- $('#foo').css('opacity', parseFloat(n));\r
- equals( $('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );\r
+ ok( jQuery('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible');\r
+ jQuery('#foo').css('display', 'none');\r
+ ok( !jQuery('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');\r
+ jQuery('#foo').css('display', 'block');\r
+ ok( jQuery('#foo').is(':visible'), 'Modified CSS display: Assert element is visible');\r
+\r
+ jQuery('#floatTest').css('styleFloat', 'left');\r
+ equals( jQuery('#floatTest').css('styleFloat'), 'left', 'Modified CSS float using "styleFloat": Assert float is left');\r
+ jQuery('#floatTest').css('cssFloat', 'right');\r
+ equals( jQuery('#floatTest').css('cssFloat'), 'right', 'Modified CSS float using "cssFloat": Assert float is right');\r
+ jQuery('#floatTest').css('float', 'left');\r
+ equals( jQuery('#floatTest').css('float'), 'left', 'Modified CSS float using "float": Assert float is left');\r
+ jQuery('#floatTest').css('font-size', '20px');\r
+ equals( jQuery('#floatTest').css('font-size'), '20px', 'Modified CSS font-size: Assert font-size is 20px');\r
+\r
+ jQuery.each("0,0.25,0.5,0.75,1".split(','), function(i, n) {\r
+ jQuery('#foo').css('opacity', n);\r
+ equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );\r
+ jQuery('#foo').css('opacity', parseFloat(n));\r
+ equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );\r
});\r
- $('#foo').css('opacity', '');\r
- equals( $('#foo').css('opacity'), '1', "Assert opacity is 1 when set to an empty String" );\r
+ jQuery('#foo').css('opacity', '');\r
+ equals( jQuery('#foo').css('opacity'), '1', "Assert opacity is 1 when set to an empty String" );\r
// for #1438, IE throws JS error when filter exists but doesn't have opacity in it\r
if (jQuery.browser.msie) {\r
- $('#foo').css("filter", "progid:DXImageTransform.Microsoft.Chroma(color='red');");\r
+ jQuery('#foo').css("filter", "progid:DXImageTransform.Microsoft.Chroma(color='red');");\r
}\r
- equals( $('#foo').css('opacity'), '1', "Assert opacity is 1 when a different filter is set in IE, #1438" );\r
+ equals( jQuery('#foo').css('opacity'), '1', "Assert opacity is 1 when a different filter is set in IE, #1438" );\r
\r
// using contents will get comments regular, text, and comment nodes\r
- var j = $("#nonnodes").contents();\r
+ var j = jQuery("#nonnodes").contents();\r
j.css("padding-left", "1px");\r
equals( j.css("padding-left"), "1px", "Check node,textnode,comment css works" );\r
\r
// opera sometimes doesn't update 'display' correctly, see #2037\r
- $("#t2037")[0].innerHTML = $("#t2037")[0].innerHTML\r
- equals( $("#t2037 .hidden").css("display"), "none", "Make sure browser thinks it is hidden" );\r
+ jQuery("#t2037")[0].innerHTML = jQuery("#t2037")[0].innerHTML\r
+ equals( jQuery("#t2037 .hidden").css("display"), "none", "Make sure browser thinks it is hidden" );\r
});\r
\r
test("jQuery.css(elem, 'height') doesn't clear radio buttons (bug #1095)", function () {\r
expect(4);\r
\r
- var $checkedtest = $("#checkedtest");\r
+ var $checkedtest = jQuery("#checkedtest");\r
// IE6 was clearing "checked" in jQuery.css(elem, "height");\r
jQuery.css($checkedtest[0], "height");\r
- ok( !! $(":radio:first", $checkedtest).attr("checked"), "Check first radio still checked." );\r
- ok( ! $(":radio:last", $checkedtest).attr("checked"), "Check last radio still NOT checked." );\r
- ok( !! $(":checkbox:first", $checkedtest).attr("checked"), "Check first checkbox still checked." );\r
- ok( ! $(":checkbox:last", $checkedtest).attr("checked"), "Check last checkbox still NOT checked." );\r
+ ok( !! jQuery(":radio:first", $checkedtest).attr("checked"), "Check first radio still checked." );\r
+ ok( ! jQuery(":radio:last", $checkedtest).attr("checked"), "Check last radio still NOT checked." );\r
+ ok( !! jQuery(":checkbox:first", $checkedtest).attr("checked"), "Check first checkbox still checked." );\r
+ ok( ! jQuery(":checkbox:last", $checkedtest).attr("checked"), "Check last checkbox still NOT checked." );\r
});\r
\r
test("width()", function() {\r
expect(9);\r
\r
- var $div = $("#nothiddendiv");\r
+ var $div = jQuery("#nothiddendiv");\r
$div.width(30);\r
equals($div.width(), 30, "Test set to 30 correctly");\r
$div.width(-1); // handle negative numbers by ignoring #1599\r
\r
$div.css({ display: "", border: "", padding: "" });\r
\r
- $("#nothiddendivchild").css({ padding: "3px", border: "2px solid #fff" });\r
- equals($("#nothiddendivchild").width(), 20, "Test child width with border and padding");\r
- $("#nothiddendiv, #nothiddendivchild").css({ border: "", padding: "", width: "" });\r
+ jQuery("#nothiddendivchild").css({ padding: "3px", border: "2px solid #fff" });\r
+ equals(jQuery("#nothiddendivchild").width(), 20, "Test child width with border and padding");\r
+ jQuery("#nothiddendiv, #nothiddendivchild").css({ border: "", padding: "", width: "" });\r
});\r
\r
test("height()", function() {\r
expect(8);\r
\r
- var $div = $("#nothiddendiv");\r
+ var $div = jQuery("#nothiddendiv");\r
$div.height(30);\r
equals($div.height(), 30, "Test set to 30 correctly");\r
$div.height(-1); // handle negative numbers by ignoring #1599\r
test("text()", function() {\r
expect(1);\r
var expected = "This link has class=\"blog\": Simon Willison's Weblog";\r
- equals( $('#sap').text(), expected, 'Check for merged text of more then one element.' );\r
+ equals( jQuery('#sap').text(), expected, 'Check for merged text of more then one element.' );\r
});\r
\r
test("wrap(String|Element)", function() {\r
expect(8);\r
var defaultText = 'Try them out:'\r
- var result = $('#first').wrap('<div class="red"><span></span></div>').text();\r
+ var result = jQuery('#first').wrap('<div class="red"><span></span></div>').text();\r
equals( defaultText, result, 'Check for wrapping of on-the-fly html' );\r
- ok( $('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );\r
+ ok( jQuery('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );\r
\r
reset();\r
var defaultText = 'Try them out:'\r
- var result = $('#first').wrap(document.getElementById('empty')).parent();\r
+ var result = jQuery('#first').wrap(document.getElementById('empty')).parent();\r
ok( result.is('ol'), 'Check for element wrapping' );\r
equals( result.text(), defaultText, 'Check for element wrapping' );\r
\r
reset();\r
- $('#check1').click(function() {\r
+ jQuery('#check1').click(function() {\r
var checkbox = this;\r
ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );\r
- $(checkbox).wrap( '<div id="c1" style="display:none;"></div>' );\r
+ jQuery(checkbox).wrap( '<div id="c1" style="display:none;"></div>' );\r
ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );\r
}).click();\r
\r
// using contents will get comments regular, text, and comment nodes\r
- var j = $("#nonnodes").contents();\r
+ var j = jQuery("#nonnodes").contents();\r
j.wrap("<i></i>");\r
- equals( $("#nonnodes > i").length, 3, "Check node,textnode,comment wraps ok" );\r
- equals( $("#nonnodes > i").text(), j.text() + j[1].nodeValue, "Check node,textnode,comment wraps doesn't hurt text" );\r
+ equals( jQuery("#nonnodes > i").length, 3, "Check node,textnode,comment wraps ok" );\r
+ equals( jQuery("#nonnodes > i").text(), j.text() + j[1].nodeValue, "Check node,textnode,comment wraps doesn't hurt text" );\r
});\r
\r
test("wrapAll(String|Element)", function() {\r
expect(8);\r
- var prev = $("#first")[0].previousSibling;\r
- var p = $("#first")[0].parentNode;\r
- var result = $('#first,#firstp').wrapAll('<div class="red"><div id="tmp"></div></div>');\r
+ var prev = jQuery("#first")[0].previousSibling;\r
+ var p = jQuery("#first")[0].parentNode;\r
+ var result = jQuery('#first,#firstp').wrapAll('<div class="red"><div id="tmp"></div></div>');\r
equals( result.parent().length, 1, 'Check for wrapping of on-the-fly html' );\r
- ok( $('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );\r
- ok( $('#firstp').parent().parent().is('.red'), 'Check if wrapper has class "red"' );\r
- equals( $("#first").parent().parent()[0].previousSibling, prev, "Correct Previous Sibling" );\r
- equals( $("#first").parent().parent()[0].parentNode, p, "Correct Parent" );\r
+ ok( jQuery('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );\r
+ ok( jQuery('#firstp').parent().parent().is('.red'), 'Check if wrapper has class "red"' );\r
+ equals( jQuery("#first").parent().parent()[0].previousSibling, prev, "Correct Previous Sibling" );\r
+ equals( jQuery("#first").parent().parent()[0].parentNode, p, "Correct Parent" );\r
\r
reset();\r
- var prev = $("#first")[0].previousSibling;\r
- var p = $("#first")[0].parentNode;\r
- var result = $('#first,#firstp').wrapAll(document.getElementById('empty'));\r
- equals( $("#first").parent()[0], $("#firstp").parent()[0], "Same Parent" );\r
- equals( $("#first").parent()[0].previousSibling, prev, "Correct Previous Sibling" );\r
- equals( $("#first").parent()[0].parentNode, p, "Correct Parent" );\r
+ var prev = jQuery("#first")[0].previousSibling;\r
+ var p = jQuery("#first")[0].parentNode;\r
+ var result = jQuery('#first,#firstp').wrapAll(document.getElementById('empty'));\r
+ equals( jQuery("#first").parent()[0], jQuery("#firstp").parent()[0], "Same Parent" );\r
+ equals( jQuery("#first").parent()[0].previousSibling, prev, "Correct Previous Sibling" );\r
+ equals( jQuery("#first").parent()[0].parentNode, p, "Correct Parent" );\r
});\r
\r
test("wrapInner(String|Element)", function() {\r
expect(6);\r
- var num = $("#first").children().length;\r
- var result = $('#first').wrapInner('<div class="red"><div id="tmp"></div></div>');\r
- equals( $("#first").children().length, 1, "Only one child" );\r
- ok( $("#first").children().is(".red"), "Verify Right Element" );\r
- equals( $("#first").children().children().children().length, num, "Verify Elements Intact" );\r
+ var num = jQuery("#first").children().length;\r
+ var result = jQuery('#first').wrapInner('<div class="red"><div id="tmp"></div></div>');\r
+ equals( jQuery("#first").children().length, 1, "Only one child" );\r
+ ok( jQuery("#first").children().is(".red"), "Verify Right Element" );\r
+ equals( jQuery("#first").children().children().children().length, num, "Verify Elements Intact" );\r
\r
reset();\r
- var num = $("#first").children().length;\r
- var result = $('#first').wrapInner(document.getElementById('empty'));\r
- equals( $("#first").children().length, 1, "Only one child" );\r
- ok( $("#first").children().is("#empty"), "Verify Right Element" );\r
- equals( $("#first").children().children().length, num, "Verify Elements Intact" );\r
+ var num = jQuery("#first").children().length;\r
+ var result = jQuery('#first').wrapInner(document.getElementById('empty'));\r
+ equals( jQuery("#first").children().length, 1, "Only one child" );\r
+ ok( jQuery("#first").children().is("#empty"), "Verify Right Element" );\r
+ equals( jQuery("#first").children().children().length, num, "Verify Elements Intact" );\r
});\r
\r
test("append(String|Element|Array<Element>|jQuery)", function() {\r
expect(21);\r
var defaultText = 'Try them out:'\r
- var result = $('#first').append('<b>buga</b>');\r
+ var result = jQuery('#first').append('<b>buga</b>');\r
equals( result.text(), defaultText + 'buga', 'Check if text appending works' );\r
- equals( $('#select3').append('<option value="appendTest">Append Test</option>').find('option:last-child').attr('value'), 'appendTest', 'Appending html options to select element');\r
+ equals( jQuery('#select3').append('<option value="appendTest">Append Test</option>').find('option:last-child').attr('value'), 'appendTest', 'Appending html options to select element');\r
\r
reset();\r
var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";\r
- $('#sap').append(document.getElementById('first'));\r
- equals( expected, $('#sap').text(), "Check for appending of element" );\r
+ jQuery('#sap').append(document.getElementById('first'));\r
+ equals( expected, jQuery('#sap').text(), "Check for appending of element" );\r
\r
reset();\r
expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";\r
- $('#sap').append([document.getElementById('first'), document.getElementById('yahoo')]);\r
- equals( expected, $('#sap').text(), "Check for appending of array of elements" );\r
+ jQuery('#sap').append([document.getElementById('first'), document.getElementById('yahoo')]);\r
+ equals( expected, jQuery('#sap').text(), "Check for appending of array of elements" );\r
\r
reset();\r
expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";\r
- $('#sap').append($("#first, #yahoo"));\r
- equals( expected, $('#sap').text(), "Check for appending of jQuery object" );\r
+ jQuery('#sap').append(jQuery("#first, #yahoo"));\r
+ equals( expected, jQuery('#sap').text(), "Check for appending of jQuery object" );\r
\r
reset();\r
- $("#sap").append( 5 );\r
- ok( $("#sap")[0].innerHTML.match( /5$/ ), "Check for appending a number" );\r
+ jQuery("#sap").append( 5 );\r
+ ok( jQuery("#sap")[0].innerHTML.match( /5$/ ), "Check for appending a number" );\r
\r
reset();\r
- $("#sap").append( " text with spaces " );\r
- ok( $("#sap")[0].innerHTML.match(/ text with spaces $/), "Check for appending text with spaces" );\r
+ jQuery("#sap").append( " text with spaces " );\r
+ ok( jQuery("#sap")[0].innerHTML.match(/ text with spaces $/), "Check for appending text with spaces" );\r
\r
reset();\r
- ok( $("#sap").append([]), "Check for appending an empty array." );\r
- ok( $("#sap").append(""), "Check for appending an empty string." );\r
- ok( $("#sap").append(document.getElementsByTagName("foo")), "Check for appending an empty nodelist." );\r
+ ok( jQuery("#sap").append([]), "Check for appending an empty array." );\r
+ ok( jQuery("#sap").append(""), "Check for appending an empty string." );\r
+ ok( jQuery("#sap").append(document.getElementsByTagName("foo")), "Check for appending an empty nodelist." );\r
\r
reset();\r
- $("#sap").append(document.getElementById('form'));\r
- equals( $("#sap>form").size(), 1, "Check for appending a form" ); // Bug #910\r
+ jQuery("#sap").append(document.getElementById('form'));\r
+ equals( jQuery("#sap>form").size(), 1, "Check for appending a form" ); // Bug #910\r
\r
reset();\r
var pass = true;\r
try {\r
- $( $("#iframe")[0].contentWindow.document.body ).append("<div>test</div>");\r
+ jQuery( jQuery("#iframe")[0].contentWindow.document.body ).append("<div>test</div>");\r
} catch(e) {\r
pass = false;\r
}\r
ok( pass, "Test for appending a DOM node to the contents of an IFrame" );\r
\r
reset();\r
- $('<fieldset/>').appendTo('#form').append('<legend id="legend">test</legend>');\r
+ jQuery('<fieldset/>').appendTo('#form').append('<legend id="legend">test</legend>');\r
t( 'Append legend', '#legend', ['legend'] );\r
\r
reset();\r
- $('#select1').append('<OPTION>Test</OPTION>');\r
- equals( $('#select1 option:last').text(), "Test", "Appending <OPTION> (all caps)" );\r
+ jQuery('#select1').append('<OPTION>Test</OPTION>');\r
+ equals( jQuery('#select1 option:last').text(), "Test", "Appending <OPTION> (all caps)" );\r
\r
- $('#table').append('<colgroup></colgroup>');\r
- ok( $('#table colgroup').length, "Append colgroup" );\r
+ jQuery('#table').append('<colgroup></colgroup>');\r
+ ok( jQuery('#table colgroup').length, "Append colgroup" );\r
\r
- $('#table colgroup').append('<col/>');\r
- ok( $('#table colgroup col').length, "Append col" );\r
+ jQuery('#table colgroup').append('<col/>');\r
+ ok( jQuery('#table colgroup col').length, "Append col" );\r
\r
reset();\r
- $('#table').append('<caption></caption>');\r
- ok( $('#table caption').length, "Append caption" );\r
+ jQuery('#table').append('<caption></caption>');\r
+ ok( jQuery('#table caption').length, "Append caption" );\r
\r
reset();\r
- $('form:last')\r
+ jQuery('form:last')\r
.append('<select id="appendSelect1"></select>')\r
.append('<select id="appendSelect2"><option>Test</option></select>');\r
\r
t( "Append Select", "#appendSelect1, #appendSelect2", ["appendSelect1", "appendSelect2"] );\r
\r
// using contents will get comments regular, text, and comment nodes\r
- var j = $("#nonnodes").contents();\r
- var d = $("<div/>").appendTo("#nonnodes").append(j);\r
- equals( $("#nonnodes").length, 1, "Check node,textnode,comment append moved leaving just the div" );\r
+ var j = jQuery("#nonnodes").contents();\r
+ var d = jQuery("<div/>").appendTo("#nonnodes").append(j);\r
+ equals( jQuery("#nonnodes").length, 1, "Check node,textnode,comment append moved leaving just the div" );\r
ok( d.contents().length >= 2, "Check node,textnode,comment append works" );\r
d.contents().appendTo("#nonnodes");\r
d.remove();\r
- ok( $("#nonnodes").contents().length >= 2, "Check node,textnode,comment append cleanup worked" );\r
+ ok( jQuery("#nonnodes").contents().length >= 2, "Check node,textnode,comment append cleanup worked" );\r
});\r
\r
test("appendTo(String|Element|Array<Element>|jQuery)", function() {\r
expect(6);\r
var defaultText = 'Try them out:'\r
- $('<b>buga</b>').appendTo('#first');\r
- equals( $("#first").text(), defaultText + 'buga', 'Check if text appending works' );\r
- equals( $('<option value="appendTest">Append Test</option>').appendTo('#select3').parent().find('option:last-child').attr('value'), 'appendTest', 'Appending html options to select element');\r
+ jQuery('<b>buga</b>').appendTo('#first');\r
+ equals( jQuery("#first").text(), defaultText + 'buga', 'Check if text appending works' );\r
+ equals( jQuery('<option value="appendTest">Append Test</option>').appendTo('#select3').parent().find('option:last-child').attr('value'), 'appendTest', 'Appending html options to select element');\r
\r
reset();\r
var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";\r
- $(document.getElementById('first')).appendTo('#sap');\r
- equals( expected, $('#sap').text(), "Check for appending of element" );\r
+ jQuery(document.getElementById('first')).appendTo('#sap');\r
+ equals( expected, jQuery('#sap').text(), "Check for appending of element" );\r
\r
reset();\r
expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";\r
- $([document.getElementById('first'), document.getElementById('yahoo')]).appendTo('#sap');\r
- equals( expected, $('#sap').text(), "Check for appending of array of elements" );\r
+ jQuery([document.getElementById('first'), document.getElementById('yahoo')]).appendTo('#sap');\r
+ equals( expected, jQuery('#sap').text(), "Check for appending of array of elements" );\r
\r
reset();\r
expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";\r
- $("#first, #yahoo").appendTo('#sap');\r
- equals( expected, $('#sap').text(), "Check for appending of jQuery object" );\r
+ jQuery("#first, #yahoo").appendTo('#sap');\r
+ equals( expected, jQuery('#sap').text(), "Check for appending of jQuery object" );\r
\r
reset();\r
- $('#select1').appendTo('#foo');\r
+ jQuery('#select1').appendTo('#foo');\r
t( 'Append select', '#foo select', ['select1'] );\r
});\r
\r
test("prepend(String|Element|Array<Element>|jQuery)", function() {\r
expect(5);\r
var defaultText = 'Try them out:'\r
- var result = $('#first').prepend('<b>buga</b>');\r
+ var result = jQuery('#first').prepend('<b>buga</b>');\r
equals( result.text(), 'buga' + defaultText, 'Check if text prepending works' );\r
- equals( $('#select3').prepend('<option value="prependTest">Prepend Test</option>').find('option:first-child').attr('value'), 'prependTest', 'Prepending html options to select element');\r
+ equals( jQuery('#select3').prepend('<option value="prependTest">Prepend Test</option>').find('option:first-child').attr('value'), 'prependTest', 'Prepending html options to select element');\r
\r
reset();\r
var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";\r
- $('#sap').prepend(document.getElementById('first'));\r
- equals( expected, $('#sap').text(), "Check for prepending of element" );\r
+ jQuery('#sap').prepend(document.getElementById('first'));\r
+ equals( expected, jQuery('#sap').text(), "Check for prepending of element" );\r
\r
reset();\r
expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";\r
- $('#sap').prepend([document.getElementById('first'), document.getElementById('yahoo')]);\r
- equals( expected, $('#sap').text(), "Check for prepending of array of elements" );\r
+ jQuery('#sap').prepend([document.getElementById('first'), document.getElementById('yahoo')]);\r
+ equals( expected, jQuery('#sap').text(), "Check for prepending of array of elements" );\r
\r
reset();\r
expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";\r
- $('#sap').prepend($("#first, #yahoo"));\r
- equals( expected, $('#sap').text(), "Check for prepending of jQuery object" );\r
+ jQuery('#sap').prepend(jQuery("#first, #yahoo"));\r
+ equals( expected, jQuery('#sap').text(), "Check for prepending of jQuery object" );\r
});\r
\r
test("prependTo(String|Element|Array<Element>|jQuery)", function() {\r
expect(6);\r
var defaultText = 'Try them out:'\r
- $('<b>buga</b>').prependTo('#first');\r
- equals( $('#first').text(), 'buga' + defaultText, 'Check if text prepending works' );\r
- equals( $('<option value="prependTest">Prepend Test</option>').prependTo('#select3').parent().find('option:first-child').attr('value'), 'prependTest', 'Prepending html options to select element');\r
+ jQuery('<b>buga</b>').prependTo('#first');\r
+ equals( jQuery('#first').text(), 'buga' + defaultText, 'Check if text prepending works' );\r
+ equals( jQuery('<option value="prependTest">Prepend Test</option>').prependTo('#select3').parent().find('option:first-child').attr('value'), 'prependTest', 'Prepending html options to select element');\r
\r
reset();\r
var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";\r
- $(document.getElementById('first')).prependTo('#sap');\r
- equals( expected, $('#sap').text(), "Check for prepending of element" );\r
+ jQuery(document.getElementById('first')).prependTo('#sap');\r
+ equals( expected, jQuery('#sap').text(), "Check for prepending of element" );\r
\r
reset();\r
expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";\r
- $([document.getElementById('yahoo'), document.getElementById('first')]).prependTo('#sap');\r
- equals( expected, $('#sap').text(), "Check for prepending of array of elements" );\r
+ jQuery([document.getElementById('yahoo'), document.getElementById('first')]).prependTo('#sap');\r
+ equals( expected, jQuery('#sap').text(), "Check for prepending of array of elements" );\r
\r
reset();\r
expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";\r
- $("#yahoo, #first").prependTo('#sap');\r
- equals( expected, $('#sap').text(), "Check for prepending of jQuery object" );\r
+ jQuery("#yahoo, #first").prependTo('#sap');\r
+ equals( expected, jQuery('#sap').text(), "Check for prepending of jQuery object" );\r
\r
reset();\r
- $('<select id="prependSelect1"></select>').prependTo('form:last');\r
- $('<select id="prependSelect2"><option>Test</option></select>').prependTo('form:last');\r
+ jQuery('<select id="prependSelect1"></select>').prependTo('form:last');\r
+ jQuery('<select id="prependSelect2"><option>Test</option></select>').prependTo('form:last');\r
\r
t( "Prepend Select", "#prependSelect1, #prependSelect2", ["prependSelect1", "prependSelect2"] );\r
});\r
test("before(String|Element|Array<Element>|jQuery)", function() {\r
expect(4);\r
var expected = 'This is a normal link: bugaYahoo';\r
- $('#yahoo').before('<b>buga</b>');\r
- equals( expected, $('#en').text(), 'Insert String before' );\r
+ jQuery('#yahoo').before('<b>buga</b>');\r
+ equals( expected, jQuery('#en').text(), 'Insert String before' );\r
\r
reset();\r
expected = "This is a normal link: Try them out:Yahoo";\r
- $('#yahoo').before(document.getElementById('first'));\r
- equals( expected, $('#en').text(), "Insert element before" );\r
+ jQuery('#yahoo').before(document.getElementById('first'));\r
+ equals( expected, jQuery('#en').text(), "Insert element before" );\r
\r
reset();\r
expected = "This is a normal link: Try them out:diveintomarkYahoo";\r
- $('#yahoo').before([document.getElementById('first'), document.getElementById('mark')]);\r
- equals( expected, $('#en').text(), "Insert array of elements before" );\r
+ jQuery('#yahoo').before([document.getElementById('first'), document.getElementById('mark')]);\r
+ equals( expected, jQuery('#en').text(), "Insert array of elements before" );\r
\r
reset();\r
expected = "This is a normal link: Try them out:diveintomarkYahoo";\r
- $('#yahoo').before($("#first, #mark"));\r
- equals( expected, $('#en').text(), "Insert jQuery before" );\r
+ jQuery('#yahoo').before(jQuery("#first, #mark"));\r
+ equals( expected, jQuery('#en').text(), "Insert jQuery before" );\r
});\r
\r
test("insertBefore(String|Element|Array<Element>|jQuery)", function() {\r
expect(4);\r
var expected = 'This is a normal link: bugaYahoo';\r
- $('<b>buga</b>').insertBefore('#yahoo');\r
- equals( expected, $('#en').text(), 'Insert String before' );\r
+ jQuery('<b>buga</b>').insertBefore('#yahoo');\r
+ equals( expected, jQuery('#en').text(), 'Insert String before' );\r
\r
reset();\r
expected = "This is a normal link: Try them out:Yahoo";\r
- $(document.getElementById('first')).insertBefore('#yahoo');\r
- equals( expected, $('#en').text(), "Insert element before" );\r
+ jQuery(document.getElementById('first')).insertBefore('#yahoo');\r
+ equals( expected, jQuery('#en').text(), "Insert element before" );\r
\r
reset();\r
expected = "This is a normal link: Try them out:diveintomarkYahoo";\r
- $([document.getElementById('first'), document.getElementById('mark')]).insertBefore('#yahoo');\r
- equals( expected, $('#en').text(), "Insert array of elements before" );\r
+ jQuery([document.getElementById('first'), document.getElementById('mark')]).insertBefore('#yahoo');\r
+ equals( expected, jQuery('#en').text(), "Insert array of elements before" );\r
\r
reset();\r
expected = "This is a normal link: Try them out:diveintomarkYahoo";\r
- $("#first, #mark").insertBefore('#yahoo');\r
- equals( expected, $('#en').text(), "Insert jQuery before" );\r
+ jQuery("#first, #mark").insertBefore('#yahoo');\r
+ equals( expected, jQuery('#en').text(), "Insert jQuery before" );\r
});\r
\r
test("after(String|Element|Array<Element>|jQuery)", function() {\r
expect(4);\r
var expected = 'This is a normal link: Yahoobuga';\r
- $('#yahoo').after('<b>buga</b>');\r
- equals( expected, $('#en').text(), 'Insert String after' );\r
+ jQuery('#yahoo').after('<b>buga</b>');\r
+ equals( expected, jQuery('#en').text(), 'Insert String after' );\r
\r
reset();\r
expected = "This is a normal link: YahooTry them out:";\r
- $('#yahoo').after(document.getElementById('first'));\r
- equals( expected, $('#en').text(), "Insert element after" );\r
+ jQuery('#yahoo').after(document.getElementById('first'));\r
+ equals( expected, jQuery('#en').text(), "Insert element after" );\r
\r
reset();\r
expected = "This is a normal link: YahooTry them out:diveintomark";\r
- $('#yahoo').after([document.getElementById('first'), document.getElementById('mark')]);\r
- equals( expected, $('#en').text(), "Insert array of elements after" );\r
+ jQuery('#yahoo').after([document.getElementById('first'), document.getElementById('mark')]);\r
+ equals( expected, jQuery('#en').text(), "Insert array of elements after" );\r
\r
reset();\r
expected = "This is a normal link: YahooTry them out:diveintomark";\r
- $('#yahoo').after($("#first, #mark"));\r
- equals( expected, $('#en').text(), "Insert jQuery after" );\r
+ jQuery('#yahoo').after(jQuery("#first, #mark"));\r
+ equals( expected, jQuery('#en').text(), "Insert jQuery after" );\r
});\r
\r
test("insertAfter(String|Element|Array<Element>|jQuery)", function() {\r
expect(4);\r
var expected = 'This is a normal link: Yahoobuga';\r
- $('<b>buga</b>').insertAfter('#yahoo');\r
- equals( expected, $('#en').text(), 'Insert String after' );\r
+ jQuery('<b>buga</b>').insertAfter('#yahoo');\r
+ equals( expected, jQuery('#en').text(), 'Insert String after' );\r
\r
reset();\r
expected = "This is a normal link: YahooTry them out:";\r
- $(document.getElementById('first')).insertAfter('#yahoo');\r
- equals( expected, $('#en').text(), "Insert element after" );\r
+ jQuery(document.getElementById('first')).insertAfter('#yahoo');\r
+ equals( expected, jQuery('#en').text(), "Insert element after" );\r
\r
reset();\r
expected = "This is a normal link: YahooTry them out:diveintomark";\r
- $([document.getElementById('mark'), document.getElementById('first')]).insertAfter('#yahoo');\r
- equals( expected, $('#en').text(), "Insert array of elements after" );\r
+ jQuery([document.getElementById('mark'), document.getElementById('first')]).insertAfter('#yahoo');\r
+ equals( expected, jQuery('#en').text(), "Insert array of elements after" );\r
\r
reset();\r
expected = "This is a normal link: YahooTry them out:diveintomark";\r
- $("#mark, #first").insertAfter('#yahoo');\r
- equals( expected, $('#en').text(), "Insert jQuery after" );\r
+ jQuery("#mark, #first").insertAfter('#yahoo');\r
+ equals( expected, jQuery('#en').text(), "Insert jQuery after" );\r
});\r
\r
test("replaceWith(String|Element|Array<Element>|jQuery)", function() {\r
expect(10);\r
- $('#yahoo').replaceWith('<b id="replace">buga</b>');\r
- ok( $("#replace")[0], 'Replace element with string' );\r
- ok( !$("#yahoo")[0], 'Verify that original element is gone, after string' );\r
+ jQuery('#yahoo').replaceWith('<b id="replace">buga</b>');\r
+ ok( jQuery("#replace")[0], 'Replace element with string' );\r
+ ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after string' );\r
\r
reset();\r
- $('#yahoo').replaceWith(document.getElementById('first'));\r
- ok( $("#first")[0], 'Replace element with element' );\r
- ok( !$("#yahoo")[0], 'Verify that original element is gone, after element' );\r
+ jQuery('#yahoo').replaceWith(document.getElementById('first'));\r
+ ok( jQuery("#first")[0], 'Replace element with element' );\r
+ ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after element' );\r
\r
reset();\r
- $('#yahoo').replaceWith([document.getElementById('first'), document.getElementById('mark')]);\r
- ok( $("#first")[0], 'Replace element with array of elements' );\r
- ok( $("#mark")[0], 'Replace element with array of elements' );\r
- ok( !$("#yahoo")[0], 'Verify that original element is gone, after array of elements' );\r
+ jQuery('#yahoo').replaceWith([document.getElementById('first'), document.getElementById('mark')]);\r
+ ok( jQuery("#first")[0], 'Replace element with array of elements' );\r
+ ok( jQuery("#mark")[0], 'Replace element with array of elements' );\r
+ ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after array of elements' );\r
\r
reset();\r
- $('#yahoo').replaceWith($("#first, #mark"));\r
- ok( $("#first")[0], 'Replace element with set of elements' );\r
- ok( $("#mark")[0], 'Replace element with set of elements' );\r
- ok( !$("#yahoo")[0], 'Verify that original element is gone, after set of elements' );\r
+ jQuery('#yahoo').replaceWith(jQuery("#first, #mark"));\r
+ ok( jQuery("#first")[0], 'Replace element with set of elements' );\r
+ ok( jQuery("#mark")[0], 'Replace element with set of elements' );\r
+ ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after set of elements' );\r
});\r
\r
test("replaceAll(String|Element|Array<Element>|jQuery)", function() {\r
expect(10);\r
- $('<b id="replace">buga</b>').replaceAll("#yahoo");\r
- ok( $("#replace")[0], 'Replace element with string' );\r
- ok( !$("#yahoo")[0], 'Verify that original element is gone, after string' );\r
+ jQuery('<b id="replace">buga</b>').replaceAll("#yahoo");\r
+ ok( jQuery("#replace")[0], 'Replace element with string' );\r
+ ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after string' );\r
\r
reset();\r
- $(document.getElementById('first')).replaceAll("#yahoo");\r
- ok( $("#first")[0], 'Replace element with element' );\r
- ok( !$("#yahoo")[0], 'Verify that original element is gone, after element' );\r
+ jQuery(document.getElementById('first')).replaceAll("#yahoo");\r
+ ok( jQuery("#first")[0], 'Replace element with element' );\r
+ ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after element' );\r
\r
reset();\r
- $([document.getElementById('first'), document.getElementById('mark')]).replaceAll("#yahoo");\r
- ok( $("#first")[0], 'Replace element with array of elements' );\r
- ok( $("#mark")[0], 'Replace element with array of elements' );\r
- ok( !$("#yahoo")[0], 'Verify that original element is gone, after array of elements' );\r
+ jQuery([document.getElementById('first'), document.getElementById('mark')]).replaceAll("#yahoo");\r
+ ok( jQuery("#first")[0], 'Replace element with array of elements' );\r
+ ok( jQuery("#mark")[0], 'Replace element with array of elements' );\r
+ ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after array of elements' );\r
\r
reset();\r
- $("#first, #mark").replaceAll("#yahoo");\r
- ok( $("#first")[0], 'Replace element with set of elements' );\r
- ok( $("#mark")[0], 'Replace element with set of elements' );\r
- ok( !$("#yahoo")[0], 'Verify that original element is gone, after set of elements' );\r
+ jQuery("#first, #mark").replaceAll("#yahoo");\r
+ ok( jQuery("#first")[0], 'Replace element with set of elements' );\r
+ ok( jQuery("#mark")[0], 'Replace element with set of elements' );\r
+ ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after set of elements' );\r
});\r
\r
test("end()", function() {\r
expect(3);\r
- equals( 'Yahoo', $('#yahoo').parent().end().text(), 'Check for end' );\r
- ok( $('#yahoo').end(), 'Check for end with nothing to end' );\r
+ equals( 'Yahoo', jQuery('#yahoo').parent().end().text(), 'Check for end' );\r
+ ok( jQuery('#yahoo').end(), 'Check for end with nothing to end' );\r
\r
- var x = $('#yahoo');\r
+ var x = jQuery('#yahoo');\r
x.parent();\r
- equals( 'Yahoo', $('#yahoo').text(), 'Check for non-destructive behaviour' );\r
+ equals( 'Yahoo', jQuery('#yahoo').text(), 'Check for non-destructive behaviour' );\r
});\r
\r
test("find(String)", function() {\r
expect(2);\r
- equals( 'Yahoo', $('#foo').find('.blogTest').text(), 'Check for find' );\r
+ equals( 'Yahoo', jQuery('#foo').find('.blogTest').text(), 'Check for find' );\r
\r
// using contents will get comments regular, text, and comment nodes\r
- var j = $("#nonnodes").contents();\r
+ var j = jQuery("#nonnodes").contents();\r
equals( j.find("div").length, 0, "Check node,textnode,comment to find zero divs" );\r
});\r
\r
test("clone()", function() {\r
expect(20);\r
- equals( 'This is a normal link: Yahoo', $('#en').text(), 'Assert text for #en' );\r
- var clone = $('#yahoo').clone();\r
- equals( 'Try them out:Yahoo', $('#first').append(clone).text(), 'Check for clone' );\r
- equals( 'This is a normal link: Yahoo', $('#en').text(), 'Reassert text for #en' );\r
+ equals( 'This is a normal link: Yahoo', jQuery('#en').text(), 'Assert text for #en' );\r
+ var clone = jQuery('#yahoo').clone();\r
+ equals( 'Try them out:Yahoo', jQuery('#first').append(clone).text(), 'Check for clone' );\r
+ equals( 'This is a normal link: Yahoo', jQuery('#en').text(), 'Reassert text for #en' );\r
\r
var cloneTags = [\r
"<table/>", "<tr/>", "<td/>", "<div/>",\r
"<tbody/>", "<thead/>", "<tfoot/>", "<iframe/>"\r
];\r
for (var i = 0; i < cloneTags.length; i++) {\r
- var j = $(cloneTags[i]);\r
+ var j = jQuery(cloneTags[i]);\r
equals( j[0].tagName, j.clone()[0].tagName, 'Clone a <' + cloneTags[i].substring(1));\r
}\r
\r
// using contents will get comments regular, text, and comment nodes\r
- var cl = $("#nonnodes").contents().clone();\r
+ var cl = jQuery("#nonnodes").contents().clone();\r
ok( cl.length >= 2, "Check node,textnode,comment clone works (some browsers delete comments on clone)" );\r
});\r
\r
test("clone() on XML nodes", function() {\r
expect(2);\r
stop();\r
- $.get("data/dashboard.xml", function (xml) {\r
- var root = $(xml.documentElement).clone();\r
- $("tab:first", xml).text("origval");\r
- $("tab:first", root).text("cloneval");\r
- equals($("tab:first", xml).text(), "origval", "Check original XML node was correctly set");\r
- equals($("tab:first", root).text(), "cloneval", "Check cloned XML node was correctly set");\r
+ jQuery.get("data/dashboard.xml", function (xml) {\r
+ var root = jQuery(xml.documentElement).clone();\r
+ jQuery("tab:first", xml).text("origval");\r
+ jQuery("tab:first", root).text("cloneval");\r
+ equals(jQuery("tab:first", xml).text(), "origval", "Check original XML node was correctly set");\r
+ equals(jQuery("tab:first", root).text(), "cloneval", "Check cloned XML node was correctly set");\r
start();\r
});\r
});\r
\r
test("is(String)", function() {\r
expect(26);\r
- ok( $('#form').is('form'), 'Check for element: A form must be a form' );\r
- ok( !$('#form').is('div'), 'Check for element: A form is not a div' );\r
- ok( $('#mark').is('.blog'), 'Check for class: Expected class "blog"' );\r
- ok( !$('#mark').is('.link'), 'Check for class: Did not expect class "link"' );\r
- ok( $('#simon').is('.blog.link'), 'Check for multiple classes: Expected classes "blog" and "link"' );\r
- ok( !$('#simon').is('.blogTest'), 'Check for multiple classes: Expected classes "blog" and "link", but not "blogTest"' );\r
- ok( $('#en').is('[lang="en"]'), 'Check for attribute: Expected attribute lang to be "en"' );\r
- ok( !$('#en').is('[lang="de"]'), 'Check for attribute: Expected attribute lang to be "en", not "de"' );\r
- ok( $('#text1').is('[type="text"]'), 'Check for attribute: Expected attribute type to be "text"' );\r
- ok( !$('#text1').is('[type="radio"]'), 'Check for attribute: Expected attribute type to be "text", not "radio"' );\r
- ok( $('#text2').is(':disabled'), 'Check for pseudoclass: Expected to be disabled' );\r
- ok( !$('#text1').is(':disabled'), 'Check for pseudoclass: Expected not disabled' );\r
- ok( $('#radio2').is(':checked'), 'Check for pseudoclass: Expected to be checked' );\r
- ok( !$('#radio1').is(':checked'), 'Check for pseudoclass: Expected not checked' );\r
- ok( $('#foo').is(':has(p)'), 'Check for child: Expected a child "p" element' );\r
- ok( !$('#foo').is(':has(ul)'), 'Check for child: Did not expect "ul" element' );\r
- ok( $('#foo').is(':has(p):has(a):has(code)'), 'Check for childs: Expected "p", "a" and "code" child elements' );\r
- ok( !$('#foo').is(':has(p):has(a):has(code):has(ol)'), 'Check for childs: Expected "p", "a" and "code" child elements, but no "ol"' );\r
- ok( !$('#foo').is(0), 'Expected false for an invalid expression - 0' );\r
- ok( !$('#foo').is(null), 'Expected false for an invalid expression - null' );\r
- ok( !$('#foo').is(''), 'Expected false for an invalid expression - ""' );\r
- ok( !$('#foo').is(undefined), 'Expected false for an invalid expression - undefined' );\r
+ ok( jQuery('#form').is('form'), 'Check for element: A form must be a form' );\r
+ ok( !jQuery('#form').is('div'), 'Check for element: A form is not a div' );\r
+ ok( jQuery('#mark').is('.blog'), 'Check for class: Expected class "blog"' );\r
+ ok( !jQuery('#mark').is('.link'), 'Check for class: Did not expect class "link"' );\r
+ ok( jQuery('#simon').is('.blog.link'), 'Check for multiple classes: Expected classes "blog" and "link"' );\r
+ ok( !jQuery('#simon').is('.blogTest'), 'Check for multiple classes: Expected classes "blog" and "link", but not "blogTest"' );\r
+ ok( jQuery('#en').is('[lang="en"]'), 'Check for attribute: Expected attribute lang to be "en"' );\r
+ ok( !jQuery('#en').is('[lang="de"]'), 'Check for attribute: Expected attribute lang to be "en", not "de"' );\r
+ ok( jQuery('#text1').is('[type="text"]'), 'Check for attribute: Expected attribute type to be "text"' );\r
+ ok( !jQuery('#text1').is('[type="radio"]'), 'Check for attribute: Expected attribute type to be "text", not "radio"' );\r
+ ok( jQuery('#text2').is(':disabled'), 'Check for pseudoclass: Expected to be disabled' );\r
+ ok( !jQuery('#text1').is(':disabled'), 'Check for pseudoclass: Expected not disabled' );\r
+ ok( jQuery('#radio2').is(':checked'), 'Check for pseudoclass: Expected to be checked' );\r
+ ok( !jQuery('#radio1').is(':checked'), 'Check for pseudoclass: Expected not checked' );\r
+ ok( jQuery('#foo').is(':has(p)'), 'Check for child: Expected a child "p" element' );\r
+ ok( !jQuery('#foo').is(':has(ul)'), 'Check for child: Did not expect "ul" element' );\r
+ ok( jQuery('#foo').is(':has(p):has(a):has(code)'), 'Check for childs: Expected "p", "a" and "code" child elements' );\r
+ ok( !jQuery('#foo').is(':has(p):has(a):has(code):has(ol)'), 'Check for childs: Expected "p", "a" and "code" child elements, but no "ol"' );\r
+ ok( !jQuery('#foo').is(0), 'Expected false for an invalid expression - 0' );\r
+ ok( !jQuery('#foo').is(null), 'Expected false for an invalid expression - null' );\r
+ ok( !jQuery('#foo').is(''), 'Expected false for an invalid expression - ""' );\r
+ ok( !jQuery('#foo').is(undefined), 'Expected false for an invalid expression - undefined' );\r
\r
// test is() with comma-seperated expressions\r
- ok( $('#en').is('[lang="en"],[lang="de"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );\r
- ok( $('#en').is('[lang="de"],[lang="en"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );\r
- ok( $('#en').is('[lang="en"] , [lang="de"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );\r
- ok( $('#en').is('[lang="de"] , [lang="en"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );\r
+ ok( jQuery('#en').is('[lang="en"],[lang="de"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );\r
+ ok( jQuery('#en').is('[lang="de"],[lang="en"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );\r
+ ok( jQuery('#en').is('[lang="en"] , [lang="de"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );\r
+ ok( jQuery('#en').is('[lang="de"] , [lang="en"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );\r
});\r
\r
-test("$.extend(Object, Object)", function() {\r
+test("jQuery.extend(Object, Object)", function() {\r
expect(20);\r
\r
var settings = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },\r
\r
test("val()", function() {\r
expect(4);\r
- equals( $("#text1").val(), "Test", "Check for value of input element" );\r
- equals( !$("#text1").val(), "", "Check for value of input element" );\r
+ equals( jQuery("#text1").val(), "Test", "Check for value of input element" );\r
+ equals( !jQuery("#text1").val(), "", "Check for value of input element" );\r
// ticket #1714 this caused a JS error in IE\r
- equals( $("#first").val(), "", "Check a paragraph element to see if it has a value" );\r
- ok( $([]).val() === undefined, "Check an empty jQuery object will return undefined from val" );\r
+ equals( jQuery("#first").val(), "", "Check a paragraph element to see if it has a value" );\r
+ ok( jQuery([]).val() === undefined, "Check an empty jQuery object will return undefined from val" );\r
});\r
\r
test("val(String)", function() {\r
expect(4);\r
document.getElementById('text1').value = "bla";\r
- equals( $("#text1").val(), "bla", "Check for modified value of input element" );\r
- $("#text1").val('test');\r
+ equals( jQuery("#text1").val(), "bla", "Check for modified value of input element" );\r
+ jQuery("#text1").val('test');\r
ok ( document.getElementById('text1').value == "test", "Check for modified (via val(String)) value of input element" );\r
\r
- $("#select1").val("3");\r
- equals( $("#select1").val(), "3", "Check for modified (via val(String)) value of select element" );\r
+ jQuery("#select1").val("3");\r
+ equals( jQuery("#select1").val(), "3", "Check for modified (via val(String)) value of select element" );\r
\r
// using contents will get comments regular, text, and comment nodes\r
- var j = $("#nonnodes").contents();\r
+ var j = jQuery("#nonnodes").contents();\r
j.val("asdf");\r
equals( j.val(), "asdf", "Check node,textnode,comment with val()" );\r
j.removeAttr("value");\r
\r
test("html(String)", function() {\r
expect(11);\r
- var div = $("#main > div");\r
+ var div = jQuery("#main > div");\r
div.html("<b>test</b>");\r
var pass = true;\r
for ( var i = 0; i < div.size(); i++ ) {\r
\r
reset();\r
// using contents will get comments regular, text, and comment nodes\r
- var j = $("#nonnodes").contents();\r
+ var j = jQuery("#nonnodes").contents();\r
j.html("<b>bold</b>");\r
\r
// this is needed, or the expando added by jQuery unique will yield a different html\r
j.find('b').removeData();\r
equals( j.html().toLowerCase(), "<b>bold</b>", "Check node,textnode,comment with html()" );\r
\r
- $("#main").html("<select/>");\r
- $("#main select").html("<option>O1</option><option selected='selected'>O2</option><option>O3</option>");\r
- equals( $("#main select").val(), "O2", "Selected option correct" );\r
+ jQuery("#main").html("<select/>");\r
+ jQuery("#main select").html("<option>O1</option><option selected='selected'>O2</option><option>O3</option>");\r
+ equals( jQuery("#main select").val(), "O2", "Selected option correct" );\r
\r
stop();\r
\r
- $("#main").html('<script type="text/javascript">ok( true, "$().html().evalScripts() Evals Scripts Twice in Firefox, see #975" );</script>');\r
+ jQuery("#main").html('<script type="text/javascript">ok( true, "jQuery().html().evalScripts() Evals Scripts Twice in Firefox, see #975" );</script>');\r
\r
- $("#main").html('foo <form><script type="text/javascript">ok( true, "$().html().evalScripts() Evals Scripts Twice in Firefox, see #975" );</script></form>');\r
+ jQuery("#main").html('foo <form><script type="text/javascript">ok( true, "jQuery().html().evalScripts() Evals Scripts Twice in Firefox, see #975" );</script></form>');\r
\r
// it was decided that waiting to execute ALL scripts makes sense since nested ones have to wait anyway so this test case is changed, see #1959\r
- $("#main").html("<script>equals(scriptorder++, 0, 'Script is executed in order');equals($('#scriptorder').length, 1,'Execute after html (even though appears before)')<\/script><span id='scriptorder'><script>equals(scriptorder++, 1, 'Script (nested) is executed in order');equals($('#scriptorder').length, 1,'Execute after html')<\/script></span><script>equals(scriptorder++, 2, 'Script (unnested) is executed in order');equals($('#scriptorder').length, 1,'Execute after html')<\/script>");\r
+ jQuery("#main").html("<script>equals(scriptorder++, 0, 'Script is executed in order');equals(jQuery('#scriptorder').length, 1,'Execute after html (even though appears before)')<\/script><span id='scriptorder'><script>equals(scriptorder++, 1, 'Script (nested) is executed in order');equals(jQuery('#scriptorder').length, 1,'Execute after html')<\/script></span><script>equals(scriptorder++, 2, 'Script (unnested) is executed in order');equals(jQuery('#scriptorder').length, 1,'Execute after html')<\/script>");\r
\r
setTimeout( start, 100 );\r
});\r
\r
test("filter()", function() {\r
expect(6);\r
- isSet( $("#form input").filter(":checked").get(), q("radio2", "check1"), "filter(String)" );\r
- isSet( $("p").filter("#ap, #sndp").get(), q("ap", "sndp"), "filter('String, String')" );\r
- isSet( $("p").filter("#ap,#sndp").get(), q("ap", "sndp"), "filter('String,String')" );\r
- isSet( $("p").filter(function() { return !$("a", this).length }).get(), q("sndp", "first"), "filter(Function)" );\r
+ isSet( jQuery("#form input").filter(":checked").get(), q("radio2", "check1"), "filter(String)" );\r
+ isSet( jQuery("p").filter("#ap, #sndp").get(), q("ap", "sndp"), "filter('String, String')" );\r
+ isSet( jQuery("p").filter("#ap,#sndp").get(), q("ap", "sndp"), "filter('String,String')" );\r
+ isSet( jQuery("p").filter(function() { return !jQuery("a", this).length }).get(), q("sndp", "first"), "filter(Function)" );\r
\r
// using contents will get comments regular, text, and comment nodes\r
- var j = $("#nonnodes").contents();\r
+ var j = jQuery("#nonnodes").contents();\r
equals( j.filter("span").length, 1, "Check node,textnode,comment to filter the one span" );\r
equals( j.filter("[name]").length, 0, "Check node,textnode,comment to filter the one span" );\r
});\r
\r
test("not()", function() {\r
expect(8);\r
- equals( $("#main > p#ap > a").not("#google").length, 2, "not('selector')" );\r
- equals( $("#main > p#ap > a").not(document.getElementById("google")).length, 2, "not(DOMElement)" );\r
- isSet( $("p").not(".result").get(), q("firstp", "ap", "sndp", "en", "sap", "first"), "not('.class')" );\r
- isSet( $("p").not("#ap, #sndp, .result").get(), q("firstp", "en", "sap", "first"), "not('selector, selector')" );\r
- isSet( $("p").not($("#ap, #sndp, .result")).get(), q("firstp", "en", "sap", "first"), "not(jQuery)" );\r
- equals( $("p").not(document.getElementsByTagName("p")).length, 0, "not(Array-like DOM collection)" );\r
- isSet( $("#form option").not("option.emptyopt:contains('Nothing'),[selected],[value='1']").get(), q("option1c", "option1d", "option2c", "option3d" ), "not('complex selector')");\r
-\r
- var selects = $("#form select");\r
+ equals( jQuery("#main > p#ap > a").not("#google").length, 2, "not('selector')" );\r
+ equals( jQuery("#main > p#ap > a").not(document.getElementById("google")).length, 2, "not(DOMElement)" );\r
+ isSet( jQuery("p").not(".result").get(), q("firstp", "ap", "sndp", "en", "sap", "first"), "not('.class')" );\r
+ isSet( jQuery("p").not("#ap, #sndp, .result").get(), q("firstp", "en", "sap", "first"), "not('selector, selector')" );\r
+ isSet( jQuery("p").not(jQuery("#ap, #sndp, .result")).get(), q("firstp", "en", "sap", "first"), "not(jQuery)" );\r
+ equals( jQuery("p").not(document.getElementsByTagName("p")).length, 0, "not(Array-like DOM collection)" );\r
+ isSet( jQuery("#form option").not("option.emptyopt:contains('Nothing'),[selected],[value='1']").get(), q("option1c", "option1d", "option2c", "option3d" ), "not('complex selector')");\r
+\r
+ var selects = jQuery("#form select");\r
isSet( selects.not( selects[1] ), q("select1", "select3"), "filter out DOM element");\r
});\r
\r
test("andSelf()", function() {\r
expect(4);\r
- isSet( $("#en").siblings().andSelf().get(), q("sndp", "sap","en"), "Check for siblings and self" );\r
- isSet( $("#foo").children().andSelf().get(), q("sndp", "en", "sap", "foo"), "Check for children and self" );\r
- isSet( $("#en, #sndp").parent().andSelf().get(), q("foo","en","sndp"), "Check for parent and self" );\r
- isSet( $("#groups").parents("p, div").andSelf().get(), q("ap", "main", "groups"), "Check for parents and self" );\r
+ isSet( jQuery("#en").siblings().andSelf().get(), q("sndp", "sap","en"), "Check for siblings and self" );\r
+ isSet( jQuery("#foo").children().andSelf().get(), q("sndp", "en", "sap", "foo"), "Check for children and self" );\r
+ isSet( jQuery("#en, #sndp").parent().andSelf().get(), q("foo","en","sndp"), "Check for parent and self" );\r
+ isSet( jQuery("#groups").parents("p, div").andSelf().get(), q("ap", "main", "groups"), "Check for parents and self" );\r
});\r
\r
test("siblings([String])", function() {\r
expect(5);\r
- isSet( $("#en").siblings().get(), q("sndp", "sap"), "Check for siblings" );\r
- isSet( $("#sndp").siblings(":has(code)").get(), q("sap"), "Check for filtered siblings (has code child element)" );\r
- isSet( $("#sndp").siblings(":has(a)").get(), q("en", "sap"), "Check for filtered siblings (has anchor child element)" );\r
- isSet( $("#foo").siblings("form, b").get(), q("form", "lengthtest", "testForm", "floatTest"), "Check for multiple filters" );\r
- isSet( $("#en, #sndp").siblings().get(), q("sndp", "sap", "en"), "Check for unique results from siblings" );\r
+ isSet( jQuery("#en").siblings().get(), q("sndp", "sap"), "Check for siblings" );\r
+ isSet( jQuery("#sndp").siblings(":has(code)").get(), q("sap"), "Check for filtered siblings (has code child element)" );\r
+ isSet( jQuery("#sndp").siblings(":has(a)").get(), q("en", "sap"), "Check for filtered siblings (has anchor child element)" );\r
+ isSet( jQuery("#foo").siblings("form, b").get(), q("form", "lengthtest", "testForm", "floatTest"), "Check for multiple filters" );\r
+ isSet( jQuery("#en, #sndp").siblings().get(), q("sndp", "sap", "en"), "Check for unique results from siblings" );\r
});\r
\r
test("children([String])", function() {\r
expect(3);\r
- isSet( $("#foo").children().get(), q("sndp", "en", "sap"), "Check for children" );\r
- isSet( $("#foo").children(":has(code)").get(), q("sndp", "sap"), "Check for filtered children" );\r
- isSet( $("#foo").children("#en, #sap").get(), q("en", "sap"), "Check for multiple filters" );\r
+ isSet( jQuery("#foo").children().get(), q("sndp", "en", "sap"), "Check for children" );\r
+ isSet( jQuery("#foo").children(":has(code)").get(), q("sndp", "sap"), "Check for filtered children" );\r
+ isSet( jQuery("#foo").children("#en, #sap").get(), q("en", "sap"), "Check for multiple filters" );\r
});\r
\r
test("parent([String])", function() {\r
expect(5);\r
- equals( $("#groups").parent()[0].id, "ap", "Simple parent check" );\r
- equals( $("#groups").parent("p")[0].id, "ap", "Filtered parent check" );\r
- equals( $("#groups").parent("div").length, 0, "Filtered parent check, no match" );\r
- equals( $("#groups").parent("div, p")[0].id, "ap", "Check for multiple filters" );\r
- isSet( $("#en, #sndp").parent().get(), q("foo"), "Check for unique results from parent" );\r
+ equals( jQuery("#groups").parent()[0].id, "ap", "Simple parent check" );\r
+ equals( jQuery("#groups").parent("p")[0].id, "ap", "Filtered parent check" );\r
+ equals( jQuery("#groups").parent("div").length, 0, "Filtered parent check, no match" );\r
+ equals( jQuery("#groups").parent("div, p")[0].id, "ap", "Check for multiple filters" );\r
+ isSet( jQuery("#en, #sndp").parent().get(), q("foo"), "Check for unique results from parent" );\r
});\r
\r
test("parents([String])", function() {\r
expect(5);\r
- equals( $("#groups").parents()[0].id, "ap", "Simple parents check" );\r
- equals( $("#groups").parents("p")[0].id, "ap", "Filtered parents check" );\r
- equals( $("#groups").parents("div")[0].id, "main", "Filtered parents check2" );\r
- isSet( $("#groups").parents("p, div").get(), q("ap", "main"), "Check for multiple filters" );\r
- isSet( $("#en, #sndp").parents().get(), q("foo", "main", "dl", "body", "html"), "Check for unique results from parents" );\r
+ equals( jQuery("#groups").parents()[0].id, "ap", "Simple parents check" );\r
+ equals( jQuery("#groups").parents("p")[0].id, "ap", "Filtered parents check" );\r
+ equals( jQuery("#groups").parents("div")[0].id, "main", "Filtered parents check2" );\r
+ isSet( jQuery("#groups").parents("p, div").get(), q("ap", "main"), "Check for multiple filters" );\r
+ isSet( jQuery("#en, #sndp").parents().get(), q("foo", "main", "dl", "body", "html"), "Check for unique results from parents" );\r
});\r
\r
test("next([String])", function() {\r
expect(4);\r
- equals( $("#ap").next()[0].id, "foo", "Simple next check" );\r
- equals( $("#ap").next("div")[0].id, "foo", "Filtered next check" );\r
- equals( $("#ap").next("p").length, 0, "Filtered next check, no match" );\r
- equals( $("#ap").next("div, p")[0].id, "foo", "Multiple filters" );\r
+ equals( jQuery("#ap").next()[0].id, "foo", "Simple next check" );\r
+ equals( jQuery("#ap").next("div")[0].id, "foo", "Filtered next check" );\r
+ equals( jQuery("#ap").next("p").length, 0, "Filtered next check, no match" );\r
+ equals( jQuery("#ap").next("div, p")[0].id, "foo", "Multiple filters" );\r
});\r
\r
test("prev([String])", function() {\r
expect(4);\r
- equals( $("#foo").prev()[0].id, "ap", "Simple prev check" );\r
- equals( $("#foo").prev("p")[0].id, "ap", "Filtered prev check" );\r
- equals( $("#foo").prev("div").length, 0, "Filtered prev check, no match" );\r
- equals( $("#foo").prev("p, div")[0].id, "ap", "Multiple filters" );\r
+ equals( jQuery("#foo").prev()[0].id, "ap", "Simple prev check" );\r
+ equals( jQuery("#foo").prev("p")[0].id, "ap", "Filtered prev check" );\r
+ equals( jQuery("#foo").prev("div").length, 0, "Filtered prev check, no match" );\r
+ equals( jQuery("#foo").prev("p, div")[0].id, "ap", "Multiple filters" );\r
});\r
\r
test("show()", function() {\r
expect(15);\r
- var pass = true, div = $("div");\r
+ var pass = true, div = jQuery("div");\r
div.show().each(function(){\r
if ( this.style.display == "none" ) pass = false;\r
});\r
ok( pass, "Show" );\r
\r
- $("#main").append('<div id="show-tests"><div><p><a href="#"></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div>');\r
+ jQuery("#main").append('<div id="show-tests"><div><p><a href="#"></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div>');\r
var test = {\r
"div" : "block",\r
"p" : "block",\r
"code" : "inline",\r
"pre" : "block",\r
"span" : "inline",\r
- "table" : $.browser.msie ? "block" : "table",\r
- "thead" : $.browser.msie ? "block" : "table-header-group",\r
- "tbody" : $.browser.msie ? "block" : "table-row-group",\r
- "tr" : $.browser.msie ? "block" : "table-row",\r
- "th" : $.browser.msie ? "block" : "table-cell",\r
- "td" : $.browser.msie ? "block" : "table-cell",\r
+ "table" : jQuery.browser.msie ? "block" : "table",\r
+ "thead" : jQuery.browser.msie ? "block" : "table-header-group",\r
+ "tbody" : jQuery.browser.msie ? "block" : "table-row-group",\r
+ "tr" : jQuery.browser.msie ? "block" : "table-row",\r
+ "th" : jQuery.browser.msie ? "block" : "table-cell",\r
+ "td" : jQuery.browser.msie ? "block" : "table-cell",\r
"ul" : "block",\r
- "li" : $.browser.msie ? "block" : "list-item"\r
+ "li" : jQuery.browser.msie ? "block" : "list-item"\r
};\r
\r
- $.each(test, function(selector, expected) {\r
- var elem = $(selector, "#show-tests").show();\r
+ jQuery.each(test, function(selector, expected) {\r
+ var elem = jQuery(selector, "#show-tests").show();\r
equals( elem.css("display"), expected, "Show using correct display type for " + selector );\r
});\r
});\r
\r
test("addClass(String)", function() {\r
expect(2);\r
- var div = $("div");\r
+ var div = jQuery("div");\r
div.addClass("test");\r
var pass = true;\r
for ( var i = 0; i < div.size(); i++ ) {\r
ok( pass, "Add Class" );\r
\r
// using contents will get regular, text, and comment nodes\r
- var j = $("#nonnodes").contents();\r
+ var j = jQuery("#nonnodes").contents();\r
j.addClass("asdf");\r
ok( j.hasClass("asdf"), "Check node,textnode,comment for addClass" );\r
});\r
\r
test("removeClass(String) - simple", function() {\r
expect(4);\r
- var div = $("div").addClass("test").removeClass("test"),\r
+ var div = jQuery("div").addClass("test").removeClass("test"),\r
pass = true;\r
for ( var i = 0; i < div.size(); i++ ) {\r
if ( div.get(i).className.indexOf("test") != -1 ) pass = false;\r
ok( pass, "Remove Class" );\r
\r
reset();\r
- var div = $("div").addClass("test").addClass("foo").addClass("bar");\r
+ var div = jQuery("div").addClass("test").addClass("foo").addClass("bar");\r
div.removeClass("test").removeClass("bar").removeClass("foo");\r
var pass = true;\r
for ( var i = 0; i < div.size(); i++ ) {\r
ok( pass, "Remove multiple classes" );\r
\r
reset();\r
- var div = $("div:eq(0)").addClass("test").removeClass("");\r
+ var div = jQuery("div:eq(0)").addClass("test").removeClass("");\r
ok( div.is('.test'), "Empty string passed to removeClass" );\r
\r
// using contents will get regular, text, and comment nodes\r
- var j = $("#nonnodes").contents();\r
+ var j = jQuery("#nonnodes").contents();\r
j.removeClass("asdf");\r
ok( !j.hasClass("asdf"), "Check node,textnode,comment for removeClass" );\r
});\r
\r
test("toggleClass(String)", function() {\r
expect(3);\r
- var e = $("#firstp");\r
+ var e = jQuery("#firstp");\r
ok( !e.is(".test"), "Assert class not present" );\r
e.toggleClass("test");\r
ok( e.is(".test"), "Assert class present" );\r
\r
test("removeAttr(String", function() {\r
expect(1);\r
- equals( $('#mark').removeAttr("class")[0].className, "", "remove class" );\r
+ equals( jQuery('#mark').removeAttr("class")[0].className, "", "remove class" );\r
});\r
\r
test("text(String)", function() {\r
expect(4);\r
- equals( $("#foo").text("<div><b>Hello</b> cruel world!</div>")[0].innerHTML, "<div><b>Hello</b> cruel world!</div>", "Check escaped text" );\r
+ equals( jQuery("#foo").text("<div><b>Hello</b> cruel world!</div>")[0].innerHTML, "<div><b>Hello</b> cruel world!</div>", "Check escaped text" );\r
\r
// using contents will get comments regular, text, and comment nodes\r
- var j = $("#nonnodes").contents();\r
+ var j = jQuery("#nonnodes").contents();\r
j.text("hi!");\r
- equals( $(j[0]).text(), "hi!", "Check node,textnode,comment with text()" );\r
+ equals( jQuery(j[0]).text(), "hi!", "Check node,textnode,comment with text()" );\r
equals( j[1].nodeValue, " there ", "Check node,textnode,comment with text()" );\r
equals( j[2].nodeType, 8, "Check node,textnode,comment with text()" );\r
});\r
\r
-test("$.each(Object,Function)", function() {\r
+test("jQuery.each(Object,Function)", function() {\r
expect(12);\r
- $.each( [0,1,2], function(i, n){\r
+ jQuery.each( [0,1,2], function(i, n){\r
equals( i, n, "Check array iteration" );\r
});\r
\r
- $.each( [5,6,7], function(i, n){\r
+ jQuery.each( [5,6,7], function(i, n){\r
equals( i, n - 5, "Check array iteration" );\r
});\r
\r
- $.each( { name: "name", lang: "lang" }, function(i, n){\r
+ jQuery.each( { name: "name", lang: "lang" }, function(i, n){\r
equals( i, n, "Check object iteration" );\r
});\r
\r
equals( total, 3, "Looping over an object, with break" );\r
});\r
\r
-test("$.prop", function() {\r
+test("jQuery.prop", function() {\r
expect(2);\r
var handle = function() { return this.id };\r
- equals( $.prop($("#ap")[0], handle), "ap", "Check with Function argument" );\r
- equals( $.prop($("#ap")[0], "value"), "value", "Check with value argument" );\r
+ equals( jQuery.prop(jQuery("#ap")[0], handle), "ap", "Check with Function argument" );\r
+ equals( jQuery.prop(jQuery("#ap")[0], "value"), "value", "Check with value argument" );\r
});\r
\r
-test("$.className", function() {\r
+test("jQuery.className", function() {\r
expect(6);\r
- var x = $("<p>Hi</p>")[0];\r
- var c = $.className;\r
+ var x = jQuery("<p>Hi</p>")[0];\r
+ var c = jQuery.className;\r
c.add(x, "hi");\r
equals( x.className, "hi", "Check single added class" );\r
c.add(x, "foo bar");\r
ok( c.has(x, "bar"), "Check has2" );\r
});\r
\r
-test("$.data", function() {\r
+test("jQuery.data", function() {\r
expect(5);\r
- var div = $("#foo")[0];\r
+ var div = jQuery("#foo")[0];\r
equals( jQuery.data(div, "test"), undefined, "Check for no data exists" );\r
jQuery.data(div, "test", "success");\r
equals( jQuery.data(div, "test"), "success", "Check for added data" );\r
\r
test(".data()", function() {\r
expect(18);\r
- var div = $("#foo");\r
+ var div = jQuery("#foo");\r
equals( div.data("test"), undefined, "Check for no data exists" );\r
div.data("test", "success");\r
equals( div.data("test"), "success", "Check for added data" );\r
equals( div.data("test.bar"), "testroot", "Check for unmatched namespace" );\r
});\r
\r
-test("$.removeData", function() {\r
+test("jQuery.removeData", function() {\r
expect(1);\r
- var div = $("#foo")[0];\r
+ var div = jQuery("#foo")[0];\r
jQuery.data(div, "test", "testing");\r
jQuery.removeData(div, "test");\r
equals( jQuery.data(div, "test"), undefined, "Check removal of data" );\r
\r
test(".removeData()", function() {\r
expect(6);\r
- var div = $("#foo");\r
+ var div = jQuery("#foo");\r
div.data("test", "testing");\r
div.removeData("test");\r
equals( div.data("test"), undefined, "Check removal of data" );\r
\r
test("remove()", function() {\r
expect(6);\r
- $("#ap").children().remove();\r
- ok( $("#ap").text().length > 10, "Check text is not removed" );\r
- equals( $("#ap").children().length, 0, "Check remove" );\r
+ jQuery("#ap").children().remove();\r
+ ok( jQuery("#ap").text().length > 10, "Check text is not removed" );\r
+ equals( jQuery("#ap").children().length, 0, "Check remove" );\r
\r
reset();\r
- $("#ap").children().remove("a");\r
- ok( $("#ap").text().length > 10, "Check text is not removed" );\r
- equals( $("#ap").children().length, 1, "Check filtered remove" );\r
+ jQuery("#ap").children().remove("a");\r
+ ok( jQuery("#ap").text().length > 10, "Check text is not removed" );\r
+ equals( jQuery("#ap").children().length, 1, "Check filtered remove" );\r
\r
// using contents will get comments regular, text, and comment nodes\r
- equals( $("#nonnodes").contents().length, 3, "Check node,textnode,comment remove works" );\r
- $("#nonnodes").contents().remove();\r
- equals( $("#nonnodes").contents().length, 0, "Check node,textnode,comment remove works" );\r
+ equals( jQuery("#nonnodes").contents().length, 3, "Check node,textnode,comment remove works" );\r
+ jQuery("#nonnodes").contents().remove();\r
+ equals( jQuery("#nonnodes").contents().length, 0, "Check node,textnode,comment remove works" );\r
});\r
\r
test("empty()", function() {\r
expect(3);\r
- equals( $("#ap").children().empty().text().length, 0, "Check text is removed" );\r
- equals( $("#ap").children().length, 4, "Check elements are not removed" );\r
+ equals( jQuery("#ap").children().empty().text().length, 0, "Check text is removed" );\r
+ equals( jQuery("#ap").children().length, 4, "Check elements are not removed" );\r
\r
// using contents will get comments regular, text, and comment nodes\r
- var j = $("#nonnodes").contents();\r
+ var j = jQuery("#nonnodes").contents();\r
j.empty();\r
equals( j.html(), "", "Check node,textnode,comment empty works" );\r
});\r
\r
test("slice()", function() {\r
expect(5);\r
- isSet( $("#ap a").slice(1,2), q("groups"), "slice(1,2)" );\r
- isSet( $("#ap a").slice(1), q("groups", "anchor1", "mark"), "slice(1)" );\r
- isSet( $("#ap a").slice(0,3), q("google", "groups", "anchor1"), "slice(0,3)" );\r
- isSet( $("#ap a").slice(-1), q("mark"), "slice(-1)" );\r
+ isSet( jQuery("#ap a").slice(1,2), q("groups"), "slice(1,2)" );\r
+ isSet( jQuery("#ap a").slice(1), q("groups", "anchor1", "mark"), "slice(1)" );\r
+ isSet( jQuery("#ap a").slice(0,3), q("google", "groups", "anchor1"), "slice(0,3)" );\r
+ isSet( jQuery("#ap a").slice(-1), q("mark"), "slice(-1)" );\r
\r
- isSet( $("#ap a").eq(1), q("groups"), "eq(1)" );\r
+ isSet( jQuery("#ap a").eq(1), q("groups"), "eq(1)" );\r
});\r
\r
test("map()", function() {\r
expect(2);//expect(6);\r
\r
isSet(\r
- $("#ap").map(function(){\r
- return $(this).find("a").get();\r
+ jQuery("#ap").map(function(){\r
+ return jQuery(this).find("a").get();\r
}),\r
q("google", "groups", "anchor1", "mark"),\r
"Array Map"\r
);\r
\r
isSet(\r
- $("#ap > a").map(function(){\r
+ jQuery("#ap > a").map(function(){\r
return this.parentNode;\r
}),\r
q("ap","ap","ap"),\r
return;//these haven't been accepted yet\r
\r
//for #2616\r
- var keys = $.map( {a:1,b:2}, function( v, k ){\r
+ var keys = jQuery.map( {a:1,b:2}, function( v, k ){\r
return k;\r
}, [ ] );\r
\r
equals( keys.join(""), "ab", "Map the keys from a hash to an array" );\r
\r
- var values = $.map( {a:1,b:2}, function( v, k ){\r
+ var values = jQuery.map( {a:1,b:2}, function( v, k ){\r
return v;\r
}, [ ] );\r
\r
equals( values.join(""), "12", "Map the values from a hash to an array" );\r
\r
var scripts = document.getElementsByTagName("script");\r
- var mapped = $.map( scripts, function( v, k ){\r
+ var mapped = jQuery.map( scripts, function( v, k ){\r
return v;\r
}, {length:0} );\r
\r
equals( mapped.length, scripts.length, "Map an array(-like) to a hash" );\r
\r
- var flat = $.map( Array(4), function( v, k ){\r
+ var flat = jQuery.map( Array(4), function( v, k ){\r
return k % 2 ? k : [k,k,k];//try mixing array and regular returns\r
});\r
\r
\r
test("contents()", function() {\r
expect(12);\r
- equals( $("#ap").contents().length, 9, "Check element contents" );\r
- ok( $("#iframe").contents()[0], "Check existance of IFrame document" );\r
- var ibody = $("#loadediframe").contents()[0].body;\r
+ equals( jQuery("#ap").contents().length, 9, "Check element contents" );\r
+ ok( jQuery("#iframe").contents()[0], "Check existance of IFrame document" );\r
+ var ibody = jQuery("#loadediframe").contents()[0].body;\r
ok( ibody, "Check existance of IFrame body" );\r
\r
- equals( $("span", ibody).text(), "span text", "Find span in IFrame and check its text" );\r
+ equals( jQuery("span", ibody).text(), "span text", "Find span in IFrame and check its text" );\r
\r
- $(ibody).append("<div>init text</div>");\r
- equals( $("div", ibody).length, 2, "Check the original div and the new div are in IFrame" );\r
+ jQuery(ibody).append("<div>init text</div>");\r
+ equals( jQuery("div", ibody).length, 2, "Check the original div and the new div are in IFrame" );\r
\r
- equals( $("div:last", ibody).text(), "init text", "Add text to div in IFrame" );\r
+ equals( jQuery("div:last", ibody).text(), "init text", "Add text to div in IFrame" );\r
\r
- $("div:last", ibody).text("div text");\r
- equals( $("div:last", ibody).text(), "div text", "Add text to div in IFrame" );\r
+ jQuery("div:last", ibody).text("div text");\r
+ equals( jQuery("div:last", ibody).text(), "div text", "Add text to div in IFrame" );\r
\r
- $("div:last", ibody).remove();\r
- equals( $("div", ibody).length, 1, "Delete the div and check only one div left in IFrame" );\r
+ jQuery("div:last", ibody).remove();\r
+ equals( jQuery("div", ibody).length, 1, "Delete the div and check only one div left in IFrame" );\r
\r
- equals( $("div", ibody).text(), "span text", "Make sure the correct div is still left after deletion in IFrame" );\r
+ equals( jQuery("div", ibody).text(), "span text", "Make sure the correct div is still left after deletion in IFrame" );\r
\r
- $("<table/>", ibody).append("<tr><td>cell</td></tr>").appendTo(ibody);\r
- $("table", ibody).remove();\r
- equals( $("div", ibody).length, 1, "Check for JS error on add and delete of a table in IFrame" );\r
+ jQuery("<table/>", ibody).append("<tr><td>cell</td></tr>").appendTo(ibody);\r
+ jQuery("table", ibody).remove();\r
+ equals( jQuery("div", ibody).length, 1, "Check for JS error on add and delete of a table in IFrame" );\r
\r
// using contents will get comments regular, text, and comment nodes\r
- var c = $("#nonnodes").contents().contents();\r
+ var c = jQuery("#nonnodes").contents().contents();\r
equals( c.length, 1, "Check node,textnode,comment contents is just one" );\r
equals( c[0].nodeValue, "hi", "Check node,textnode,comment contents is just the one from span" );\r
});\r
\r
-test("$.makeArray", function(){\r
+test("jQuery.makeArray", function(){\r
expect(15);\r
\r
- equals( $.makeArray($('html>*'))[0].nodeName, "HEAD", "Pass makeArray a jQuery object" );\r
+ equals( jQuery.makeArray(jQuery('html>*'))[0].nodeName, "HEAD", "Pass makeArray a jQuery object" );\r
\r
- equals( $.makeArray(document.getElementsByName("PWD")).slice(0,1)[0].name, "PWD", "Pass makeArray a nodelist" );\r
+ equals( jQuery.makeArray(document.getElementsByName("PWD")).slice(0,1)[0].name, "PWD", "Pass makeArray a nodelist" );\r
\r
- equals( (function(){ return $.makeArray(arguments); })(1,2).join(""), "12", "Pass makeArray an arguments array" );\r
+ equals( (function(){ return jQuery.makeArray(arguments); })(1,2).join(""), "12", "Pass makeArray an arguments array" );\r
\r
- equals( $.makeArray([1,2,3]).join(""), "123", "Pass makeArray a real array" );\r
+ equals( jQuery.makeArray([1,2,3]).join(""), "123", "Pass makeArray a real array" );\r
\r
- equals( $.makeArray().length, 0, "Pass nothing to makeArray and expect an empty array" );\r
+ equals( jQuery.makeArray().length, 0, "Pass nothing to makeArray and expect an empty array" );\r
\r
- equals( $.makeArray( 0 )[0], 0 , "Pass makeArray a number" );\r
+ equals( jQuery.makeArray( 0 )[0], 0 , "Pass makeArray a number" );\r
\r
- equals( $.makeArray( "foo" )[0], "foo", "Pass makeArray a string" );\r
+ equals( jQuery.makeArray( "foo" )[0], "foo", "Pass makeArray a string" );\r
\r
- equals( $.makeArray( true )[0].constructor, Boolean, "Pass makeArray a boolean" );\r
+ equals( jQuery.makeArray( true )[0].constructor, Boolean, "Pass makeArray a boolean" );\r
\r
- equals( $.makeArray( document.createElement("div") )[0].nodeName, "DIV", "Pass makeArray a single node" );\r
+ equals( jQuery.makeArray( document.createElement("div") )[0].nodeName, "DIV", "Pass makeArray a single node" );\r
\r
- equals( $.makeArray( {length:2, 0:"a", 1:"b"} ).join(""), "ab", "Pass makeArray an array like map (with length)" );\r
+ equals( jQuery.makeArray( {length:2, 0:"a", 1:"b"} ).join(""), "ab", "Pass makeArray an array like map (with length)" );\r
\r
- ok( !!$.makeArray( document.documentElement.childNodes ).slice(0,1)[0].nodeName, "Pass makeArray a childNodes array" );\r
+ ok( !!jQuery.makeArray( document.documentElement.childNodes ).slice(0,1)[0].nodeName, "Pass makeArray a childNodes array" );\r
\r
//function, is tricky as it has length\r
- equals( $.makeArray( function(){ return 1;} )[0](), 1, "Pass makeArray a function" );\r
+ equals( jQuery.makeArray( function(){ return 1;} )[0](), 1, "Pass makeArray a function" );\r
//window, also has length\r
- equals( $.makeArray(window)[0], window, "Pass makeArray the window" );\r
+ equals( jQuery.makeArray(window)[0], window, "Pass makeArray the window" );\r
\r
- equals( $.makeArray(/a/)[0].constructor, RegExp, "Pass makeArray a regex" );\r
+ equals( jQuery.makeArray(/a/)[0].constructor, RegExp, "Pass makeArray a regex" );\r
\r
- ok( $.makeArray(document.getElementById('form')).length >= 13, "Pass makeArray a form (treat as elements)" );\r
+ ok( jQuery.makeArray(document.getElementById('form')).length >= 13, "Pass makeArray a form (treat as elements)" );\r
});\r