aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJörn Zaefferer <joern.zaefferer@gmail.com>2006-11-18 13:37:01 +0000
committerJörn Zaefferer <joern.zaefferer@gmail.com>2006-11-18 13:37:01 +0000
commit7cc550727c4e0bcd93c5d435f0799f568fc74dfa (patch)
tree62a407183988fa13b4f2d0f6a5165444683d740d
parent797ccbaf3185e501a52b5a3517126fdbab03764c (diff)
downloadjquery-7cc550727c4e0bcd93c5d435f0799f568fc74dfa.tar.gz
jquery-7cc550727c4e0bcd93c5d435f0799f568fc74dfa.zip
Testsuite 2.0
-rw-r--r--build.xml18
-rw-r--r--build/test/data/test.js1
-rw-r--r--build/test/data/testrunner.js115
-rw-r--r--build/test/index.html18
-rw-r--r--src/ajax/ajax.js220
-rw-r--r--src/ajax/ajaxTest.js271
-rw-r--r--src/event/event.js51
-rw-r--r--src/event/eventTest.js11
-rw-r--r--src/fx/fx.js8
-rw-r--r--src/fx/fxTest.js12
-rw-r--r--src/jquery/coreTest.js549
-rw-r--r--src/jquery/jquery.js402
12 files changed, 930 insertions, 746 deletions
diff --git a/build.xml b/build.xml
index 2d13c31fb..7424dbf41 100644
--- a/build.xml
+++ b/build.xml
@@ -45,10 +45,10 @@
<mkdir dir="${DIST_DIR}" />
<concat destfile="${JQ}">
<fileset dir="${SRC_DIR}" includes="intro.js" />
- <fileset dir="${SRC_DIR}" includes="jquery/*.js" />
- <fileset dir="${SRC_DIR}" includes="event/*.js" />
- <fileset dir="${SRC_DIR}" includes="fx/*.js" />
- <fileset dir="${SRC_DIR}" includes="ajax/*.js" />
+ <fileset dir="${SRC_DIR}" includes="jquery/jquery.js" />
+ <fileset dir="${SRC_DIR}" includes="event/event.js" />
+ <fileset dir="${SRC_DIR}" includes="fx/fx.js" />
+ <fileset dir="${SRC_DIR}" includes="ajax/ajax.js" />
<fileset dir="${PLUGIN_DIR}" includes="${PLUGINS}" />
<fileset dir="${SRC_DIR}" includes="outro.js" />
</concat>
@@ -101,18 +101,14 @@
<echo message="${JQ_PACK} built." />
</target>
- <target name="test" depends="jquery" description="Reads tests from source and compiles into html file, testsuite must be run on a webserver">
+ <target name="test" depends="jquery" description="Copy files for the test suite into their own directory.">
<echo message="Building Test Suite" />
<delete dir="${TEST_DIR}" />
<mkdir dir="${TEST_DIR}/data" />
<copy todir="${TEST_DIR}/data">
<fileset dir="${BUILD_DIR}/test/data/" />
- </copy>
- <java jar="${JAR}" fork="true">
- <arg value="${BUILD_DIR}/test/test.js" />
- <arg value="${JQ}" />
- <arg value="${TEST_DIR}" />
- </java>
+ </copy>
+ <copy todir="${TEST_DIR}" file="${BUILD_DIR}/test/index.html" />
<echo message="Test Suite built." />
</target>
diff --git a/build/test/data/test.js b/build/test/data/test.js
index 9294f06b7..6ff89dd49 100644
--- a/build/test/data/test.js
+++ b/build/test/data/test.js
@@ -1,2 +1,3 @@
foobar = "bar";
$('#ap').html('bar');
+ok( true, "test.js executed"); \ No newline at end of file
diff --git a/build/test/data/testrunner.js b/build/test/data/testrunner.js
index 06d12cb29..c3afea339 100644
--- a/build/test/data/testrunner.js
+++ b/build/test/data/testrunner.js
@@ -1,59 +1,69 @@
-var asyncTimeout = 2 // seconds for async timeout
-
-var fixture;
-var Test;
-var stats = {
- all: 0,
- bad: 0
+var _config = {
+ fixture: null,
+ Test: [],
+ stats: {
+ all: 0,
+ bad: 0
+ },
+ queue: [],
+ blocking: true,
+ timeout: null,
+ expected: null,
+ currentModule: null,
+ asyncTimeout: 2 // seconds for async timeout
};
-var queue = [];
-var blocking = false;
-var timeout;
+
+$(function() {
+ $('#userAgent').html(navigator.userAgent);
+ runTest();
+});
function synchronize(callback) {
- queue[queue.length] = callback;
- if(!blocking) {
+ _config.queue[_config.queue.length] = callback;
+ if(!_config.blocking) {
process();
}
}
function process() {
- while(queue.length && !blocking) {
- var call = queue[0];
- queue = queue.slice(1);
+ while(_config.queue.length && !_config.blocking) {
+ var call = _config.queue[0];
+ _config.queue = _config.queue.slice(1);
call();
}
}
function stop() {
- blocking = true;
- timeout = setTimeout(start, asyncTimeout * 1000);
+ _config.blocking = true;
+ _config.timeout = setTimeout(start, _config.asyncTimeout * 1000);
}
function start() {
- if(timeout)
- clearTimeout(timeout);
- blocking = false;
+ if(_config.timeout)
+ clearTimeout(_config.timeout);
+ _config.blocking = false;
process();
}
-function runTest(tests) {
- var startTime = new Date();
- fixture = document.getElementById('main').innerHTML;
- tests();
+function runTest() {
+ _config.blocking = false;
+ var time = new Date();
+ _config.fixture = document.getElementById('main').innerHTML;
synchronize(function() {
- var runTime = new Date() - startTime;
- var result = document.createElement("div");
- result.innerHTML = ['<p class="result">Tests completed in ',
- runTime, ' milliseconds.<br/>',
- stats.bad, ' tests of ', stats.all, ' failed.</p>'].join('');
- document.getElementsByTagName("body")[0].appendChild(result);
- $("<div id='banner'>").addClass(stats.bad ? "fail" : "pass").insertAfter("h1");
+ time = new Date() - time;
+ $("<div>").html(['<p class="result">Tests completed in ',
+ time, ' milliseconds.<br/>',
+ _config.stats.bad, ' tests of ', _config.stats.all, ' failed.</p>']
+ .join(''))
+ .appendTo("body");
+ $("<div id='banner'>").addClass(_config.stats.bad ? "fail" : "pass").insertAfter("h1");
});
}
function test(name, callback) {
+ if(_config.currentModule)
+ name = _config.currentModule + " module: " + name;
synchronize(function() {
- Test = [];
+ _config.Test = [];
try {
callback();
} catch(e) {
@@ -62,27 +72,32 @@ function test(name, callback) {
console.error(e);
console.warn(callback.toString());
}
- Test.push( [ false, "Died on test #" + (Test.length+1) + ": " + e ] );
+ _config.Test.push( [ false, "Died on test #" + (_config.Test.length+1) + ": " + e ] );
}
});
synchronize(function() {
reset();
+ if(_config.expected && _config.expected != _config.Test.length) {
+ _config.Test.push( [ false, "Expected " + _config.expected + " assertions, but " + _config.Test.length + " were run" ] );
+ }
+ _config.expected = null;
+
var good = 0, bad = 0;
var ol = document.createElement("ol");
ol.style.display = "none";
var li = "", state = "pass";
- for ( var i = 0; i < Test.length; i++ ) {
+ for ( var i = 0; i < _config.Test.length; i++ ) {
var li = document.createElement("li");
- li.className = Test[i][0] ? "pass" : "fail";
- li.innerHTML = Test[i][1];
+ li.className = _config.Test[i][0] ? "pass" : "fail";
+ li.innerHTML = _config.Test[i][1];
ol.appendChild( li );
- stats.all++;
- if ( !Test[i][0] ) {
+ _config.stats.all++;
+ if ( !_config.Test[i][0] ) {
state = "fail";
bad++;
- stats.bad++;
+ _config.stats.bad++;
} else good++;
}
@@ -90,7 +105,7 @@ function test(name, callback) {
li.className = state;
var b = document.createElement("b");
- b.innerHTML = name + " <b style='color:black;'>(<b class='fail'>" + bad + "</b>, <b class='pass'>" + good + "</b>, " + Test.length + ")</b>";
+ b.innerHTML = name + " <b style='color:black;'>(<b class='fail'>" + bad + "</b>, <b class='pass'>" + good + "</b>, " + _config.Test.length + ")</b>";
b.onclick = function(){
var n = this.nextSibling;
if ( jQuery.css( n, "display" ) == "none" )
@@ -105,11 +120,23 @@ function test(name, callback) {
});
}
+// call on start of module test to prepend name to all tests
+function module(moduleName) {
+ _config.currentModule = moduleName;
+}
+
+/**
+ * Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through.
+ */
+function expect(asserts) {
+ _config.expected = asserts;
+}
+
/**
* Resets the test setup. Useful for tests that modify the DOM.
*/
function reset() {
- document.getElementById('main').innerHTML = fixture;
+ document.getElementById('main').innerHTML = _config.fixture;
}
/**
@@ -117,7 +144,7 @@ function reset() {
* @example ok( $("a").size() > 5, "There must be at least 5 anchors" );
*/
function ok(a, msg) {
- Test.push( [ !!a, msg ] );
+ _config.Test.push( [ !!a, msg ] );
}
/**
@@ -132,9 +159,9 @@ function isSet(a, b, msg) {
} else
ret = false;
if ( !ret )
- Test.push( [ ret, msg + " expected: " + b + " result: " + a ] );
+ _config.Test.push( [ ret, msg + " expected: " + b + " result: " + a ] );
else
- Test.push( [ ret, msg ] );
+ _config.Test.push( [ ret, msg ] );
}
/**
diff --git a/build/test/index.html b/build/test/index.html
index 1a8c176a0..db6cfd813 100644
--- a/build/test/index.html
+++ b/build/test/index.html
@@ -1,19 +1,17 @@
<html id="html">
<head>
+ <title>jQuery Test Suite</title>
+ <link rel="Stylesheet" media="screen" href="data/testsuite.css" />
<script type="text/javascript" src="../dist/jquery.js"></script>
<script type="text/javascript" src="data/testrunner.js"></script>
- <script>
- $(document).ready(function(){
- $('#userAgent').html(navigator.userAgent);
- runTest(function() {
- {TESTS}
- });
- });
- </script>
- <link rel="Stylesheet" media="screen" href="data/testsuite.css" />
+ <script type="text/javascript" src="../src/jquery/coreTest.js"></script>
+ <script type="text/javascript" src="../src/event/eventTest.js"></script>
+ <script type="text/javascript" src="../src/ajax/ajaxTest.js"></script>
+ <script type="text/javascript" src="../src/fx/fxTest.js"></script>
</head>
+
<body id="body">
- <h1 id="banner">jQuery Core - Test Suite</h1>
+ <h1 id="banner">jQuery Test Suite - Core</h1>
<h2 id="userAgent"></h2>
<!-- Test HTML -->
diff --git a/src/ajax/ajax.js b/src/ajax/ajax.js
index c30f9138f..e5a3854cf 100644
--- a/src/ajax/ajax.js
+++ b/src/ajax/ajax.js
@@ -33,34 +33,6 @@ jQuery.fn.extend({
* @desc Same as above, but with an additional parameter
* and a callback that is executed when the data was loaded.
*
- * @test stop();
- * $('#first').load("data/name.php", function() {
- * ok( $('#first').text() == 'ERROR', 'Check if content was injected into the DOM' );
- * start();
- * });
- *
- * @test stop(); // check if load can be called with only url
- * $('#first').load("data/name.php");
- * $.get("data/name.php", function() {
- * ok( $('#first').text() == 'ERROR', 'Check if load works without callback');
- * start();
- * });
- *
- * @test stop();
- * window.foobar = undefined;
- * window.foo = undefined;
- * var verifyEvaluation = function() {
- * ok( foobar == "bar", 'Check if script src was evaluated after load' );
- * ok( $('#foo').html() == 'foo', 'Check if script evaluation has modified DOM');
- * ok( $('#ap').html() == 'bar', 'Check if script evaluation has modified DOM');
- * start();
- * };
- * $('#first').load('data/test.html', function() {
- * ok( $('#first').html().match(/^html text/), 'Check content after loading html' );
- * ok( foo == "foo", 'Check if script was evaluated after load' );
- * setTimeout(verifyEvaluation, 600);
- * });
- *
* @name load
* @type jQuery
* @param String url The URL of the HTML file to load.
@@ -129,10 +101,6 @@ jQuery.fn.extend({
* @after name=John&location=Boston
* @desc Serialize a selection of input elements to a string
*
- * @test var data = $(':input').not('button').serialize();
- * // ignore button, IE takes text content as value, not relevant for this test
- * ok( data == 'action=Test&text2=Test&radio1=on&radio2=on&check=on&=on&hidden=&foo[bar]=&name=name&=foobar&select1=&select2=3&select3=1', 'Check form serialization as query string' );
- *
* @name serialize
* @type String
* @cat AJAX
@@ -244,51 +212,6 @@ if ( jQuery.browser.msie && typeof XMLHttpRequest == "undefined" )
* @cat AJAX
*/
-/**
- * @test stop(); var counter = { complete: 0, success: 0, error: 0 };
- * var success = function() { counter.success++ };
- * var error = function() { counter.error++ };
- * var complete = function() { counter.complete++ };
- * $('#foo').ajaxStart(complete).ajaxStop(complete).ajaxComplete(complete).ajaxError(error).ajaxSuccess(success);
- * // start with successful test
- * $.ajax({url: "data/name.php", success: success, error: error, complete: function() {
- * ok( counter.error == 0, 'Check succesful request' );
- * ok( counter.success == 2, 'Check succesful request' );
- * ok( counter.complete == 3, 'Check succesful request' );
- * counter.error = 0; counter.success = 0; counter.complete = 0;
- * $.ajaxTimeout(500);
- * $.ajax({url: "data/name.php?wait=5", success: success, error: error, complete: function() {
- * ok( counter.error == 2, 'Check failed request' );
- * ok( counter.success == 0, 'Check failed request' );
- * ok( counter.complete == 3, 'Check failed request' );
- * start();
- * }});
- * }});
-
- * @test stop(); var counter = { complete: 0, success: 0, error: 0 };
- * counter.error = 0; counter.success = 0; counter.complete = 0;
- * var success = function() { counter.success++ };
- * var error = function() { counter.error++ };
- * $.ajaxTimeout(0);
- * $.ajax({url: "data/name.php", global: false, success: success, error: error, complete: function() {
- * ok( counter.error == 0, 'Check sucesful request without globals' );
- * ok( counter.success == 1, 'Check sucesful request without globals' );
- * ok( counter.complete == 0, 'Check sucesful request without globals' );
- * counter.error = 0; counter.success = 0; counter.complete = 0;
- * $.ajaxTimeout(500);
- * $.ajax({url: "data/name.php?wait=5", global: false, success: success, error: error, complete: function() {
- * ok( counter.error == 1, 'Check failed request without globals' );
- * ok( counter.success == 0, 'Check failed request without globals' );
- * ok( counter.complete == 0, 'Check failed request without globals' );
- * start();
- * }});
- * }});
- *
- * @name ajaxHandlersTesting
- * @private
- */
-
-
new function(){
var e = "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess".split(",");
@@ -321,17 +244,6 @@ jQuery.extend({
* }
* )
*
- * @test stop();
- * $.get('data/dashboard.xml', function(xml) {
- * var content = [];
- * $('tab', xml).each(function() {
- * content.push($(this).text());
- * });
- * ok( content[0] == 'blabla', 'Check first tab');
- * ok( content[1] == 'blublu', 'Check second tab');
- * start();
- * });
- *
* @name $.get
* @type undefined
* @param String url The URL of the page to load.
@@ -376,12 +288,6 @@ jQuery.extend({
* }
* )
*
- * @test stop();
- * $.getIfModified("data/name.php", function(msg) {
- * ok( msg == 'ERROR', 'Check ifModified' );
- * start();
- * });
- *
* @name $.getIfModified
* @type undefined
* @param String url The URL of the page to load.
@@ -403,16 +309,6 @@ jQuery.extend({
* alert("Script loaded and executed.");
* })
*
- * @test stop();
- * $.getScript("data/test.js", function() {
- * ok( foobar == "bar", 'Check if script was evaluated' );
- * start();
- * });
- *
- * @test
- * $.getScript("data/test.js");
- * ok( true, "Check with single argument, can't verify" );
- *
* @name $.getScript
* @type undefined
* @param String url The URL of the page to load.
@@ -442,21 +338,6 @@ jQuery.extend({
* }
* )
*
- * @test stop();
- * $.getJSON("data/json.php", {json: "array"}, function(json) {
- * ok( json[0].name == 'John', 'Check JSON: first, name' );
- * ok( json[0].age == 21, 'Check JSON: first, age' );
- * ok( json[1].name == 'Peter', 'Check JSON: second, name' );
- * ok( json[1].age == 25, 'Check JSON: second, age' );
- * start();
- * });
- * @test stop();
- * $.getJSON("data/json.php", function(json) {
- * ok( json.data.lang == 'en', 'Check JSON: lang' );
- * ok( json.data.length == 25, 'Check JSON: length' );
- * start();
- * });
- *
* @name $.getJSON
* @type undefined
* @param String url The URL of the page to load.
@@ -487,15 +368,6 @@ jQuery.extend({
* }
* )
*
- * @test stop();
- * $.post("data/name.php", {xml: "5-2"}, function(xml){
- * $('math', xml).each(function() {
- * ok( $('calculation', this).text() == '5-2', 'Check for XML' );
- * ok( $('result', this).text() == '3', 'Check for XML' );
- * });
- * start();
- * });
- *
* @name $.post
* @type undefined
* @param String url The URL of the page to load.
@@ -525,50 +397,6 @@ jQuery.extend({
* @example $.ajaxTimeout( 5000 );
* @desc Make all AJAX requests timeout after 5 seconds.
*
- * @test stop();
- * var passed = 0;
- * var timeout;
- * $.ajaxTimeout(1000);
- * var pass = function() {
- * passed++;
- * if(passed == 2) {
- * ok( true, 'Check local and global callbacks after timeout' );
- * clearTimeout(timeout);
- * $('#main').unbind("ajaxError");
- * start();
- * }
- * };
- * var fail = function() {
- * ok( false, 'Check for timeout failed' );
- * start();
- * };
- * timeout = setTimeout(fail, 1500);
- * $('#main').ajaxError(pass);
- * $.ajax({
- * type: "GET",
- * url: "data/name.php?wait=5",
- * error: pass,
- * success: fail
- * });
- *
- * @test stop(); $.ajaxTimeout(50);
- * $.ajax({
- * type: "GET",
- * timeout: 5000,
- * url: "data/name.php?wait=1",
- * error: function() {
- * ok( false, 'Check for local timeout failed' );
- * start();
- * },
- * success: function() {
- * ok( true, 'Check for local timeout' );
- * start();
- * }
- * });
- * // reset timeout
- * $.ajaxTimeout(0);
- *
- *
* @name $.ajaxTimeout
* @type undefined
* @param Number time How long before an AJAX request times out.
@@ -671,54 +499,6 @@ jQuery.extend({
* });
* @desc Save some data to the server and notify the user once its complete.
*
- * @test stop();
- * $.ajax({
- * type: "GET",
- * url: "data/name.php?name=foo",
- * success: function(msg){
- * ok( msg == 'bar', 'Check for GET' );
- * start();
- * }
- * });
- *
- * @test stop();
- * $.ajax({
- * type: "POST",
- * url: "data/name.php",
- * data: "name=peter",
- * success: function(msg){
- * ok( msg == 'pan', 'Check for POST' );
- * start();
- * }
- * });
- *
- * @test stop();
- * window.foobar = undefined;
- * window.foo = undefined;
- * var verifyEvaluation = function() {
- * ok( foobar == "bar", 'Check if script src was evaluated for datatype html' );
- * start();
- * };
- * $.ajax({
- * dataType: "html",
- * url: "data/test.html",
- * success: function(data) {
- * ok( data.match(/^html text/), 'Check content for datatype html' );
- * ok( foo == "foo", 'Check if script was evaluated for datatype html' );
- * setTimeout(verifyEvaluation, 600);
- * }
- * });
- *
- * @test stop();
- * $.ajax({
- * url: "data/with_fries.xml", dataType: "xml", type: "GET", data: "", success: function(resp) {
- * ok( $("properties", resp).length == 1, 'properties in responseXML' );
- * ok( $("jsconf", resp).length == 1, 'jsconf in responseXML' );
- * ok( $("thing", resp).length == 2, 'things in responseXML' );
- * start();
- * }
- * });
- *
* @name $.ajax
* @type XMLHttpRequest
* @param Hash prop A set of properties to initialize the request with.
diff --git a/src/ajax/ajaxTest.js b/src/ajax/ajaxTest.js
new file mode 100644
index 000000000..0462aadcd
--- /dev/null
+++ b/src/ajax/ajaxTest.js
@@ -0,0 +1,271 @@
+module("ajax");
+
+test("load(String, Object, Function) - simple: inject text into DOM", function() {
+ expect(1);
+ stop();
+ $('#first').load("data/name.php", function() {
+ ok( $('#first').text() == 'ERROR', 'Check if content was injected into the DOM' );
+ start();
+ });
+});
+
+test("load(String, Object, Function) - inject without callback", function() {
+ expect(1);
+ stop(); // check if load can be called with only url
+ $('#first').load("data/name.php");
+ $.get("data/name.php", function() {
+ ok( $('#first').text() == 'ERROR', 'Check if load works without callback');
+ start();
+ });
+});
+
+test("load(String, Object, Function) - check scripts", function() {
+ expect(6);
+ stop();
+ window.foobar = undefined;
+ window.foo = undefined;
+ var verifyEvaluation = function() {
+ ok( foobar == "bar", 'Check if script src was evaluated after load' );
+ ok( $('#foo').html() == 'foo', 'Check if script evaluation has modified DOM');
+ ok( $('#ap').html() == 'bar', 'Check if script evaluation has modified DOM');
+ start();
+ };
+ $('#first').load('data/test.html', function() {
+ ok( $('#first').html().match(/^html text/), 'Check content after loading html' );
+ ok( foo == "foo", 'Check if script was evaluated after load' );
+ setTimeout(verifyEvaluation, 600);
+ });
+});
+
+test("serialize()", function() {
+ expect(1);
+ var data = $(':input').not('button').serialize();
+ // ignore button, IE takes text content as value, not relevant for this test
+ ok( data == 'action=Test&text2=Test&radio1=on&radio2=on&check=on&=on&hidden=&foo[bar]=&name=name&=foobar&select1=&select2=3&select3=1', 'Check form serialization as query string' );
+});
+
+test("test global handlers - success", function() {
+ expect(6);
+ stop();
+ var counter = { complete: 0, success: 0, error: 0 },
+ success = function() { counter.success++ },
+ error = function() { counter.error++ },
+ complete = function() { counter.complete++ };
+
+ $('#foo').ajaxStart(complete).ajaxStop(complete).ajaxComplete(complete).ajaxError(error).ajaxSuccess(success);
+ // start with successful test
+ $.ajax({url: "data/name.php", success: success, error: error, complete: function() {
+ ok( counter.error == 0, 'Check succesful request' );
+ ok( counter.success == 2, 'Check succesful request' );
+ ok( counter.complete == 3, 'Check succesful request' );
+ counter.error = counter.success = counter.complete = 0;
+ $.ajaxTimeout(500);
+ $.ajax({url: "data/name.php?wait=5", success: success, error: error, complete: function() {
+ ok( counter.error == 2, 'Check failed request' );
+ ok( counter.success == 0, 'Check failed request' );
+ ok( counter.complete == 3, 'Check failed request' );
+ start();
+ }});
+ }});
+});
+
+test("test global handlers - failure", function() {
+ expect(6);
+ stop();
+ var counter = { complete: 0, success: 0, error: 0 },
+ success = function() { counter.success++ },
+ error = function() { counter.error++ };
+ $.ajaxTimeout(0);
+ $.ajax({url: "data/name.php", global: false, success: success, error: error, complete: function() {
+ ok( counter.error == 0, 'Check sucesful request without globals' );
+ ok( counter.success == 1, 'Check sucesful request without globals' );
+ ok( counter.complete == 0, 'Check sucesful request without globals' );
+ counter.error = counter.success = counter.complete = 0;
+ $.ajaxTimeout(500);
+ $.ajax({url: "data/name.php?wait=5", global: false, success: success, error: error, complete: function() {
+ ok( counter.error == 1, 'Check failed request without globals' );
+ ok( counter.success == 0, 'Check failed request without globals' );
+ ok( counter.complete == 0, 'Check failed request without globals' );
+ start();
+ }});
+ }});
+});
+
+test("$.get(String, Hash, Function) - parse xml and use text() on nodes", function() {
+ expect(2);
+ stop();
+ $.get('data/dashboard.xml', function(xml) {
+ var content = [];
+ $('tab', xml).each(function() {
+ content.push($(this).text());
+ });
+ ok( content[0] == 'blabla', 'Check first tab');
+ ok( content[1] == 'blublu', 'Check second tab');
+ start();
+ });
+});
+
+test("$.getIfModified(String, Hash, Function)", function() {
+ expect(1);
+ stop();
+ $.getIfModified("data/name.php", function(msg) {
+ ok( msg == 'ERROR', 'Check ifModified' );
+ start();
+ });
+});
+
+test("$.getScript(String, Function) - with callback", function() {
+ expect(2);
+ stop();
+ $.getScript("data/test.js", function() {
+ ok( foobar == "bar", 'Check if script was evaluated' );
+ start();
+ });
+});
+
+test("$.getScript(String, Function) - no callback", function() {
+ expect(1);
+ stop();
+ $.getScript("data/test.js");
+});
+
+test("$.getJSON(String, Hash, Function) - JSON array", function() {
+ expect(4);
+ stop();
+ $.getJSON("data/json.php", {json: "array"}, function(json) {
+ ok( json[0].name == 'John', 'Check JSON: first, name' );
+ ok( json[0].age == 21, 'Check JSON: first, age' );
+ ok( json[1].name == 'Peter', 'Check JSON: second, name' );
+ ok( json[1].age == 25, 'Check JSON: second, age' );
+ start();
+ });
+});
+
+test("$.getJSON(String, Hash, Function) - JSON object", function() {
+ expect(2);
+ stop();
+ $.getJSON("data/json.php", function(json) {
+ ok( json.data.lang == 'en', 'Check JSON: lang' );
+ ok( json.data.length == 25, 'Check JSON: length' );
+ start();
+ });
+});
+
+test("$.post(String, Hash, Function) - simple with xml", function() {
+ expect(2);
+ stop();
+ $.post("data/name.php", {xml: "5-2"}, function(xml){
+ $('math', xml).each(function() {
+ ok( $('calculation', this).text() == '5-2', 'Check for XML' );
+ ok( $('result', this).text() == '3', 'Check for XML' );
+ });
+ start();
+ });
+});
+
+test("$.ajaxTimeout(Number) - with global timeout", function() {
+ stop();
+ var passed = 0;
+ var timeout;
+ $.ajaxTimeout(1000);
+ var pass = function() {
+ passed++;
+ if(passed == 2) {
+ ok( true, 'Check local and global callbacks after timeout' );
+ clearTimeout(timeout);
+ $('#main').unbind("ajaxError");
+ start();
+ }
+ };
+ var fail = function() {
+ ok( false, 'Check for timeout failed' );
+ start();
+ };
+ timeout = setTimeout(fail, 1500);
+ $('#main').ajaxError(pass);
+ $.ajax({
+ type: "GET",
+ url: "data/name.php?wait=5",
+ error: pass,
+ success: fail
+ });
+});
+
+test("$.ajaxTimeout(Number) with localtimeout", function() {
+ stop(); $.ajaxTimeout(50);
+ $.ajax({
+ type: "GET",
+ timeout: 5000,
+ url: "data/name.php?wait=1",
+ error: function() {
+ ok( false, 'Check for local timeout failed' );
+ start();
+ },
+ success: function() {
+ ok( true, 'Check for local timeout' );
+ start();
+ }
+ });
+ // reset timeout
+ $.ajaxTimeout(0);
+});
+
+test("$.ajax - simple get", function() {
+ expect(1);
+ stop();
+ $.ajax({
+ type: "GET",
+ url: "data/name.php?name=foo",
+ success: function(msg){
+ ok( msg == 'bar', 'Check for GET' );
+ start();
+ }
+ });
+});
+
+test("$.ajax - simple post", function() {
+ expect(1);
+ stop();
+ $.ajax({
+ type: "POST",
+ url: "data/name.php",
+ data: "name=peter",
+ success: function(msg){
+ ok( msg == 'pan', 'Check for POST' );
+ start();
+ }
+ });
+});
+
+test("$.ajax - dataType html", function() {
+ expect(4);
+ stop();
+ window.foobar = undefined;
+ window.foo = undefined;
+ var verifyEvaluation = function() {
+ ok( foobar == "bar", 'Check if script src was evaluated for datatype html' );
+ start();
+ };
+ $.ajax({
+ dataType: "html",
+ url: "data/test.html",
+ success: function(data) {
+ ok( data.match(/^html text/), 'Check content for datatype html' );
+ ok( foo == "foo", 'Check if script was evaluated for datatype html' );
+ setTimeout(verifyEvaluation, 600);
+ }
+ });
+});
+
+test("$.ajax - xml: non-namespace elements inside namespaced elements", function() {
+ expect(3);
+ stop();
+ $.ajax({
+ url: "data/with_fries.xml", dataType: "xml", type: "GET", data: "", success: function(resp) {
+ ok( $("properties", resp).length == 1, 'properties in responseXML' );
+ ok( $("jsconf", resp).length == 1, 'jsconf in responseXML' );
+ ok( $("thing", resp).length == 2, 'things in responseXML' );
+ start();
+ }
+ });
+}); \ No newline at end of file
diff --git a/src/event/event.js b/src/event/event.js
index 19bb4f6a3..921e52427 100644
--- a/src/event/event.js
+++ b/src/event/event.js
@@ -16,13 +16,6 @@ jQuery.fn.extend({
* $(this).removeClass("selected");
* });
*
- * @test var count = 0;
- * var fn1 = function() { count++; }
- * var fn2 = function() { count--; }
- * var link = $('#mark');
- * link.click().toggle(fn1, fn2).click().click().click().click().click();
- * ok( count == 1, "Check for toggle(fn, fn)" );
- *
* @name toggle
* @type jQuery
* @param Function even The function to execute on every even click.
@@ -1527,50 +1520,6 @@ new function(){
* @type jQuery
* @cat Events/Mouse
*/
-
- /**
- * @test var count;
- * // ignore load
- * var e = ("blur,focus,resize,scroll,unload,click,dblclick," +
- * "mousedown,mouseup,mousemove,mouseover,mouseout,change,reset,select," +
- * "submit,keydown,keypress,keyup,error").split(",");
- * var handler1 = function(event) {
- * count++;
- * };
- * var handler2 = function(event) {
- * count++;
- * };
- * for( var i=0; i < e.length; i++) {
- * var event = e[i];
- * count = 0;
- * // bind handler
- * $(document)[event](handler1);
- * $(document)[event](handler2);
- * $(document)["one"+event](handler1);
- *
- * // call event two times
- * $(document)[event]();
- * $(document)[event]();
- *
- * // unbind events
- * $(document)["un"+event](handler1);
- * // call once more
- * $(document)[event]();
- *
- * // remove all handlers
- * $(document)["un"+event]();
- *
- * // call once more
- * $(document)[event]();
- *
- * // assert count
- * ok( count == 6, 'Checking event ' + event);
- * }
- *
- * @private
- * @name eventTesting
- * @cat Events
- */
var e = ("blur,focus,load,resize,scroll,unload,click,dblclick," +
"mousedown,mouseup,mousemove,mouseover,mouseout,change,reset,select," +
diff --git a/src/event/eventTest.js b/src/event/eventTest.js
new file mode 100644
index 000000000..b597a2527
--- /dev/null
+++ b/src/event/eventTest.js
@@ -0,0 +1,11 @@
+module("event");
+
+test("toggle(Function, Function) - add toggle event and fake a few clicks", function() {
+ expect(1);
+ var count = 0,
+ fn1 = function() { count++; },
+ fn2 = function() { count--; },
+ link = $('#mark');
+ link.click().toggle(fn1, fn2).click().click().click().click().click();
+ ok( count == 1, "Check for toggle(fn, fn)" );
+}); \ No newline at end of file
diff --git a/src/fx/fx.js b/src/fx/fx.js
index b8d3d37d7..7c2218e14 100644
--- a/src/fx/fx.js
+++ b/src/fx/fx.js
@@ -305,14 +305,6 @@ jQuery.fn.extend({
* left: 50, opacity: 'show'
* }, 500);
*
- * @test stop();
- * var hash = {opacity: 'show'};
- * var hashCopy = $.extend({}, hash);
- * $('#foo').animate(hash, 'fast', function() {
- * ok( hash.opacity == hashCopy.opacity, 'Check if animate changed the hash parameter' );
- * start();
- * });
- *
* @name animate
* @type jQuery
* @param Hash params A set of style attributes that you wish to animate, and to what end.
diff --git a/src/fx/fxTest.js b/src/fx/fxTest.js
new file mode 100644
index 000000000..8c29de638
--- /dev/null
+++ b/src/fx/fxTest.js
@@ -0,0 +1,12 @@
+module("fx");
+
+test("animate(Hash, Object, Function) - assert that animate doesn't modify its arguments", function() {
+ expect(1);
+ stop();
+ var hash = {opacity: 'show'};
+ var hashCopy = $.extend({}, hash);
+ $('#foo').animate(hash, 'fast', function() {
+ ok( hash.opacity == hashCopy.opacity, 'Check if animate changed the hash parameter' );
+ start();
+ });
+}); \ No newline at end of file
diff --git a/src/jquery/coreTest.js b/src/jquery/coreTest.js
new file mode 100644
index 000000000..3f674c0b4
--- /dev/null
+++ b/src/jquery/coreTest.js
@@ -0,0 +1,549 @@
+module("core");
+
+test("Basic requirements", function() {
+ expect(7);
+ ok( Array.prototype.push, "Array.push()" );
+ ok( Function.prototype.apply, "Function.apply()" );
+ ok( document.getElementById, "getElementById" );
+ ok( document.getElementsByTagName, "getElementsByTagName" );
+ ok( RegExp, "RegExp" );
+ ok( jQuery, "jQuery" );
+ ok( $, "$()" );
+});
+
+test("length", function() {
+ ok( $("div").length == 2, "Get Number of Elements Found" );
+});
+
+test("size()", function() {
+ ok( $("div").size() == 2, "Get Number of Elements Found" );
+});
+
+test("get()", function() {
+ isSet( $("div").get(), q("main","foo"), "Get All Elements" );
+});
+
+test("get(Number)", function() {
+ ok( $("div").get(0) == document.getElementById("main"), "Get A Single Element" );
+});
+
+test("each(Function)", function() {
+ expect(1);
+ var div = $("div");
+ div.each(function(){this.foo = 'zoo';});
+ var pass = true;
+ for ( var i = 0; i < div.size(); i++ ) {
+ if ( div.get(i).foo != "zoo" ) pass = false;
+ }
+ ok( pass, "Execute a function, Relative" );
+});
+
+test("index(Object)", function() {
+ expect(8);
+ ok( $([window, document]).index(window) == 0, "Check for index of elements" );
+ ok( $([window, document]).index(document) == 1, "Check for index of elements" );
+ var inputElements = $('#radio1,#radio2,#check1,#check2');
+ ok( inputElements.index(document.getElementById('radio1')) == 0, "Check for index of elements" );
+ ok( inputElements.index(document.getElementById('radio2')) == 1, "Check for index of elements" );
+ ok( inputElements.index(document.getElementById('check1')) == 2, "Check for index of elements" );
+ ok( inputElements.index(document.getElementById('check2')) == 3, "Check for index of elements" );
+ ok( inputElements.index(window) == -1, "Check for not found index" );
+ ok( inputElements.index(document) == -1, "Check for not found index" );
+});
+
+test("attr(String)", function() {
+ expect(12);
+ ok( $('#text1').attr('value') == "Test", 'Check for value attribute' );
+ ok( $('#text1').attr('type') == "text", 'Check for type attribute' );
+ ok( $('#radio1').attr('type') == "radio", 'Check for type attribute' );
+ ok( $('#check1').attr('type') == "checkbox", 'Check for type attribute' );
+ ok( $('#simon1').attr('rel') == "bookmark", 'Check for rel attribute' );
+ ok( $('#google').attr('title') == "Google!", 'Check for title attribute' );
+ ok( $('#mark').attr('hreflang') == "en", 'Check for hreflang attribute' );
+ ok( $('#en').attr('lang') == "en", 'Check for lang attribute' );
+ ok( $('#simon').attr('class') == "blog link", 'Check for class attribute' );
+ ok( $('#name').attr('name') == "name", 'Check for name attribute' );
+ ok( $('#text1').attr('name') == "action", 'Check for name attribute' );
+ ok( $('#form').attr('action').indexOf("formaction") >= 0, 'Check for action attribute' );
+});
+
+test("attr(Hash)", function() {
+ expect(1);
+ var pass = true;
+ $("div").attr({foo: 'baz', zoo: 'ping'}).each(function(){
+ if ( this.getAttribute('foo') != "baz" && this.getAttribute('zoo') != "ping" ) pass = false;
+ });
+ ok( pass, "Set Multiple Attributes" );
+});
+
+test("attr(String, Object)", function() {
+ expect(6);
+ var div = $("div");
+ div.attr("foo", "bar");
+ var pass = true;
+ for ( var i = 0; i < div.size(); i++ ) {
+ if ( div.get(i).getAttribute('foo') != "bar" ) pass = false;
+ }
+ ok( pass, "Set Attribute" );
+
+ $("#name").attr('name', 'something');
+ ok( $("#name").name() == 'something', 'Set name attribute' );
+ $("#check2").attr('checked', true);
+ ok( document.getElementById('check2').checked == true, 'Set checked attribute' );
+ $("#check2").attr('checked', false);
+ ok( document.getElementById('check2').checked == false, 'Set checked attribute' );
+ $("#text1").attr('readonly', true);
+ ok( document.getElementById('text1').readOnly == true, 'Set readonly attribute' );
+ $("#text1").attr('readonly', false);
+ ok( document.getElementById('text1').readOnly == false, 'Set readonly attribute' );
+});
+
+test("attr(String, Object)x", function() {
+ expect(2);
+ stop();
+ $.get('data/dashboard.xml', function(xml) {
+ var titles = [];
+ $('tab', xml).each(function() {
+ titles.push($(this).attr('title'));
+ });
+ ok( titles[0] == 'Location', 'attr() in XML context: Check first title' );
+ ok( titles[1] == 'Users', 'attr() in XML context: Check second title' );
+ start();
+ });
+});
+
+test("css(String|Hash)", function() {
+ expect(8);
+
+ ok( $('#main').css("display") == 'none', 'Check for css property "display"');
+
+ ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible');
+ $('#foo').css({display: 'none'});
+ ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');
+ $('#foo').css({display: 'block'});
+ ok( $('#foo').is(':visible'), 'Modified CSS display: Assert element is visible');
+
+ $('#floatTest').css({styleFloat: 'right'});
+ ok( $('#floatTest').css('styleFloat') == 'right', 'Modified CSS float using "styleFloat": Assert float is right');
+ $('#floatTest').css({cssFloat: 'left'});
+ ok( $('#floatTest').css('cssFloat') == 'left', 'Modified CSS float using "cssFloat": Assert float is left');
+ $('#floatTest').css({'float': 'right'});
+ ok( $('#floatTest').css('float') == 'right', 'Modified CSS float using "float": Assert float is right');
+ $('#floatTest').css({'font-size': '30px'});
+ ok( $('#floatTest').css('font-size') == '30px', 'Modified CSS font-size: Assert font-size is 30px');
+});
+
+test("css(String, Object)", function() {
+ expect(7);
+ ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible');
+ $('#foo').css('display', 'none');
+ ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');
+ $('#foo').css('display', 'block');
+ ok( $('#foo').is(':visible'), 'Modified CSS display: Assert element is visible');
+
+ $('#floatTest').css('styleFloat', 'left');
+ ok( $('#floatTest').css('styleFloat') == 'left', 'Modified CSS float using "styleFloat": Assert float is left');
+ $('#floatTest').css('cssFloat', 'right');
+ ok( $('#floatTest').css('cssFloat') == 'right', 'Modified CSS float using "cssFloat": Assert float is right');
+ $('#floatTest').css('float', 'left');
+ ok( $('#floatTest').css('float') == 'left', 'Modified CSS float using "float": Assert float is left');
+ $('#floatTest').css('font-size', '20px');
+ ok( $('#floatTest').css('font-size') == '20px', 'Modified CSS font-size: Assert font-size is 20px');
+});
+
+test("text()", function() {
+ var expected = "This link has class=\"blog\": Simon Willison's Weblog";
+ ok( $('#sap').text() == expected, 'Check for merged text of more then one element.' );
+});
+
+test("wrap(String|Element)", function() {
+ expect(4);
+ var defaultText = 'Try them out:'
+ var result = $('#first').wrap('<div class="red"><span></span></div>').text();
+ ok( defaultText == result, 'Check for wrapping of on-the-fly html' );
+ ok( $('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
+
+ reset();
+ var defaultText = 'Try them out:'
+ var result = $('#first').wrap(document.getElementById('empty')).parent();
+ ok( result.is('ol'), 'Check for element wrapping' );
+ ok( result.text() == defaultText, 'Check for element wrapping' );
+});
+
+test("append(String|Element|Array&lt;Element&gt;)", function() {
+ expect(4);
+ var defaultText = 'Try them out:'
+ var result = $('#first').append('<b>buga</b>');
+ ok( result.text() == defaultText + 'buga', 'Check if text appending works' );
+ ok( $('#select3').append('<option value="appendTest">Append Test</option>').find('option:last-child').attr('value') == 'appendTest', 'Appending html options to select element');
+
+ reset();
+ expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
+ $('#sap').append(document.getElementById('first'));
+ ok( expected == $('#sap').text(), "Check for appending of element" );
+
+ reset();
+ expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
+ $('#sap').append([document.getElementById('first'), document.getElementById('yahoo')]);
+ ok( expected == $('#sap').text(), "Check for appending of array of elements" );
+});
+
+test("prepend(String|Element|Array&lt;Element&gt;)", function() {
+ expect(4);
+ var defaultText = 'Try them out:'
+ var result = $('#first').prepend('<b>buga</b>');
+ ok( result.text() == 'buga' + defaultText, 'Check if text prepending works' );
+ ok( $('#select3').prepend('<option value="prependTest">Prepend Test</option>').find('option:first-child').attr('value') == 'prependTest', 'Prepending html options to select element');
+
+ reset();
+ expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
+ $('#sap').prepend(document.getElementById('first'));
+ ok( expected == $('#sap').text(), "Check for prepending of element" );
+
+ reset();
+ expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
+ $('#sap').prepend([document.getElementById('first'), document.getElementById('yahoo')]);
+ ok( expected == $('#sap').text(), "Check for prepending of array of elements" );
+});
+
+test("before(String|Element|Array&lt;Element&gt;)", function() {
+ expect(3);
+ var expected = 'This is a normal link: bugaYahoo';
+ $('#yahoo').before('<b>buga</b>');
+ ok( expected == $('#en').text(), 'Insert String before' );
+
+ reset();
+ expected = "This is a normal link: Try them out:Yahoo";
+ $('#yahoo').before(document.getElementById('first'));
+ ok( expected == $('#en').text(), "Insert element before" );
+
+ reset();
+ expected = "This is a normal link: Try them out:diveintomarkYahoo";
+ $('#yahoo').before([document.getElementById('first'), document.getElementById('mark')]);
+ ok( expected == $('#en').text(), "Insert array of elements before" );
+});
+
+test("after(String|Element|Array&lt;Element&gt;)", function() {
+ expect(3);
+ var expected = 'This is a normal link: Yahoobuga';
+ $('#yahoo').after('<b>buga</b>');
+ ok( expected == $('#en').text(), 'Insert String after' );
+
+ reset();
+ expected = "This is a normal link: YahooTry them out:";
+ $('#yahoo').after(document.getElementById('first'));
+ ok( expected == $('#en').text(), "Insert element after" );
+
+ reset();
+ expected = "This is a normal link: YahooTry them out:diveintomark";
+ $('#yahoo').after([document.getElementById('first'), document.getElementById('mark')]);
+ ok( expected == $('#en').text(), "Insert array of elements after" );
+});
+
+test("end()", function() {
+ expect(2);
+ ok( 'Yahoo' == $('#yahoo').parent().end().text(), 'Check for end' );
+ ok( $('#yahoo').end(), 'Check for end with nothing to end' );
+});
+
+test("find(String)", function() {
+ ok( 'Yahoo' == $('#foo').find('.blogTest').text(), 'Check for find' );
+});
+
+test("clone()", function() {
+ expect(3);
+ ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Assert text for #en' );
+ var clone = $('#yahoo').clone();
+ ok( 'Try them out:Yahoo' == $('#first').append(clone).text(), 'Check for clone' );
+ ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Reassert text for #en' );
+});
+
+test("filter(String)", function() {
+ isSet( $("input").filter(":checked").get(), q("radio2", "check1"), "Filter elements" );
+});
+
+test("filter(String) - execute callback in fitting context", function() {
+ expect(1);
+ $("input").filter(":checked",function(i){
+ ok( this == q("radio2", "check1")[i], "Filter elements, context" );
+ });
+});
+
+test("filter(String) - execute callback in not-fitting context", function() {
+ expect(1);
+ $("#main > p#ap > a").filter("#foobar",function(){},function(i){
+ ok( this == q("google","groups", "mark")[i], "Filter elements, else context" );
+ });
+});
+
+test("not(String)", function() {
+ ok($("#main > p#ap > a").not("#google").length == 2, ".not")
+});
+
+test("is(String)", function() {
+ expect(22);
+ ok( $('#form').is('form'), 'Check for element: A form must be a form' );
+ ok( !$('#form').is('div'), 'Check for element: A form is not a div' );
+ ok( $('#mark').is('.blog'), 'Check for class: Expected class "blog"' );
+ ok( !$('#mark').is('.link'), 'Check for class: Did not expect class "link"' );
+ ok( $('#simon').is('.blog.link'), 'Check for multiple classes: Expected classes "blog" and "link"' );
+ ok( !$('#simon').is('.blogTest'), 'Check for multiple classes: Expected classes "blog" and "link", but not "blogTest"' );
+ ok( $('#en').is('[@lang="en"]'), 'Check for attribute: Expected attribute lang to be "en"' );
+ ok( !$('#en').is('[@lang="de"]'), 'Check for attribute: Expected attribute lang to be "en", not "de"' );
+ ok( $('#text1').is('[@type="text"]'), 'Check for attribute: Expected attribute type to be "text"' );
+ ok( !$('#text1').is('[@type="radio"]'), 'Check for attribute: Expected attribute type to be "text", not "radio"' );
+ ok( $('#text2').is(':disabled'), 'Check for pseudoclass: Expected to be disabled' );
+ ok( !$('#text1').is(':disabled'), 'Check for pseudoclass: Expected not disabled' );
+ ok( $('#radio2').is(':checked'), 'Check for pseudoclass: Expected to be checked' );
+ ok( !$('#radio1').is(':checked'), 'Check for pseudoclass: Expected not checked' );
+ ok( $('#foo').is('[p]'), 'Check for child: Expected a child "p" element' );
+ ok( !$('#foo').is('[ul]'), 'Check for child: Did not expect "ul" element' );
+ ok( $('#foo').is('[p][a][code]'), 'Check for childs: Expected "p", "a" and "code" child elements' );
+ ok( !$('#foo').is('[p][a][code][ol]'), 'Check for childs: Expected "p", "a" and "code" child elements, but no "ol"' );
+ ok( !$('#foo').is(0), 'Expected false for an invalid expression - 0' );
+ ok( !$('#foo').is(null), 'Expected false for an invalid expression - null' );
+ ok( !$('#foo').is(''), 'Expected false for an invalid expression - ""' );
+ ok( !$('#foo').is(undefined), 'Expected false for an invalid expression - undefined' );
+});
+
+test("$.extend(Object, Object)", function() {
+ expect(2);
+ var settings = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
+ options = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
+ optionsCopy = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
+ merged = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "x", xxx: "newstring" };
+ jQuery.extend(settings, options);
+ isSet( settings, merged, "Check if extended: settings must be extended" );
+ isSet ( options, optionsCopy, "Check if not modified: options must not be modified" );
+});
+
+test("expressions - element", function() {
+ expect(5);
+ ok( $("*").size() >= 30, "Select all" );
+ t( "Element Selector", "div", ["main","foo"] );
+ t( "Element Selector", "body", ["body"] );
+ t( "Element Selector", "html", ["html"] );
+ t( "Parent Element", "div div", ["foo"] );
+});
+
+test("expressions - id", function() {
+ expect(5);
+ t( "ID Selector", "#body", ["body"] );
+ t( "ID Selector w/ Element", "body#body", ["body"] );
+ t( "ID Selector w/ Element", "ul#first", [] );
+
+ t( "All Children of ID", "#foo/*", ["sndp", "en", "sap"] );
+ t( "All Children of ID with no children", "#firstUL/*", [] );
+});
+
+test("expressions - class", function() {
+ expect(4);
+ t( "Class Selector", ".blog", ["mark","simon"] );
+ t( "Class Selector", ".blog.link", ["simon"] );
+ t( "Class Selector w/ Element", "a.blog", ["mark","simon"] );
+ t( "Parent Class Selector", "p .blog", ["mark","simon"] );
+});
+
+test("expressions - multiple", function() {
+ expect(4);
+ t( "Comma Support", "a.blog, div", ["mark","simon","main","foo"] );
+ t( "Comma Support", "a.blog , div", ["mark","simon","main","foo"] );
+ t( "Comma Support", "a.blog ,div", ["mark","simon","main","foo"] );
+ t( "Comma Support", "a.blog,div", ["mark","simon","main","foo"] );
+});
+
+test("expressions - child and adjacent", function() {
+ expect(14);
+ t( "Child", "p > a", ["simon1","google","groups","mark","yahoo","simon"] );
+ t( "Child", "p> a", ["simon1","google","groups","mark","yahoo","simon"] );
+ t( "Child", "p >a", ["simon1","google","groups","mark","yahoo","simon"] );
+ t( "Child", "p>a", ["simon1","google","groups","mark","yahoo","simon"] );
+ t( "Child w/ Class", "p > a.blog", ["mark","simon"] );
+ t( "All Children", "code > *", ["anchor1","anchor2"] );
+ t( "All Grandchildren", "p > * > *", ["anchor1","anchor2"] );
+ t( "Adjacent", "a + a", ["groups"] );
+ t( "Adjacent", "a +a", ["groups"] );
+ t( "Adjacent", "a+ a", ["groups"] );
+ t( "Adjacent", "a+a", ["groups"] );
+ t( "Adjacent", "p + p", ["ap","en","sap"] );
+ t( "Comma, Child, and Adjacent", "a + a, code > a", ["groups","anchor1","anchor2"] );
+ t( "First Child", "p:first-child", ["firstp","sndp"] );
+});
+
+test("expressions - attributes", function() {
+ expect(16);
+ t( "Attribute Exists", "a[@title]", ["google"] );
+ t( "Attribute Exists", "*[@title]", ["google"] );
+ t( "Attribute Exists", "[@title]", ["google"] );
+
+ t( "Attribute Equals", "a[@rel='bookmark']", ["simon1"] );
+ t( "Attribute Equals", 'a[@rel="bookmark"]', ["simon1"] );
+ t( "Attribute Equals", "a[@rel=bookmark]", ["simon1"] );
+ t( "Multiple Attribute Equals", "input[@type='hidden'],input[@type='radio']", ["hidden1","radio1","radio2"] );
+ t( "Multiple Attribute Equals", "input[@type=\"hidden\"],input[@type='radio']", ["hidden1","radio1","radio2"] );
+ t( "Multiple Attribute Equals", "input[@type=hidden],input[@type=radio]", ["hidden1","radio1","radio2"] );
+
+ t( "Attribute Begins With", "a[@href ^= 'http://www']", ["google","yahoo"] );
+ t( "Attribute Ends With", "a[@href $= 'org/']", ["mark"] );
+ t( "Attribute Contains", "a[@href *= 'google']", ["google","groups"] );
+
+ t( "Grouped Form Elements", "input[@name='foo[bar]']", ["hidden2"] );
+
+ t( ":not() Existing attribute", "select:not([@multiple])", ["select1", "select2"]);
+ t( ":not() Equals attribute", "select:not([@name=select1])", ["select2", "select3"]);
+ t( ":not() Equals quoted attribute", "select:not([@name='select1'])", ["select2", "select3"]);
+});
+
+test("expressions - pseudo (:) selctors", function() {
+ expect(30);
+ t( "First Child", "p:first-child", ["firstp","sndp"] );
+ t( "Last Child", "p:last-child", ["sap"] );
+ t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2"] );
+ t( "Empty", "ul:empty", ["firstUL"] );
+ t( "Enabled UI Element", "input:enabled", ["text1","radio1","radio2","check1","check2","hidden1","hidden2","name"] );
+ t( "Disabled UI Element", "input:disabled", ["text2"] );
+ t( "Checked UI Element", "input:checked", ["radio2","check1"] );
+ t( "Selected Option Element", "option:selected", ["option1a","option2d","option3b","option3c"] );
+ t( "Text Contains", "a:contains('Google')", ["google","groups"] );
+ t( "Text Contains", "a:contains('Google Groups')", ["groups"] );
+ t( "Element Preceded By", "p ~ div", ["foo"] );
+ t( "Not", "a.blog:not(.link)", ["mark"] );
+
+ t( "nth Element", "p:nth(1)", ["ap"] );
+ t( "First Element", "p:first", ["firstp"] );
+ t( "Last Element", "p:last", ["first"] );
+ t( "Even Elements", "p:even", ["firstp","sndp","sap"] );
+ t( "Odd Elements", "p:odd", ["ap","en","first"] );
+ t( "Position Equals", "p:eq(1)", ["ap"] );
+ t( "Position Greater Than", "p:gt(0)", ["ap","sndp","en","sap","first"] );
+ t( "Position Less Than", "p:lt(3)", ["firstp","ap","sndp"] );
+ t( "Is A Parent", "p:parent", ["firstp","ap","sndp","en","sap","first"] );
+ t( "Is Visible", "input:visible", ["text1","text2","radio1","radio2","check1","check2","name"] );
+ t( "Is Hidden", "input:hidden", ["hidden1","hidden2"] );
+
+ t( "Form element :input", ":input", ["text1", "text2", "radio1", "radio2", "check1", "check2", "hidden1", "hidden2", "name", "button", "area1", "select1", "select2", "select3"] );
+ t( "Form element :radio", ":radio", ["radio1", "radio2"] );
+ t( "Form element :checkbox", ":checkbox", ["check1", "check2"] );
+ t( "Form element :text", ":text", ["text1", "text2", "hidden2", "name"] );
+ t( "Form element :radio:checked", ":radio:checked", ["radio2"] );
+ t( "Form element :checkbox:checked", ":checkbox:checked", ["check1"] );
+ t( "Form element :checkbox:checked, :radio:checked", ":checkbox:checked, :radio:checked", ["check1", "radio2"] );
+});
+
+test("expressions - basic xpath", function() {
+ expect(14);
+ ok( jQuery.find("//*").length >= 30, "All Elements (//*)" );
+ t( "All Div Elements", "//div", ["main","foo"] );
+ t( "Absolute Path", "/html/body", ["body"] );
+ t( "Absolute Path w/ *", "/* /body", ["body"] );
+ t( "Long Absolute Path", "/html/body/dl/div/div/p", ["sndp","en","sap"] );
+ t( "Absolute and Relative Paths", "/html//div", ["main","foo"] );
+ t( "All Children, Explicit", "//code/*", ["anchor1","anchor2"] );
+ t( "All Children, Implicit", "//code/", ["anchor1","anchor2"] );
+ t( "Attribute Exists", "//a[@title]", ["google"] );
+ t( "Attribute Equals", "//a[@rel='bookmark']", ["simon1"] );
+ t( "Parent Axis", "//p/..", ["main","foo"] );
+ t( "Sibling Axis", "//p/../", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","sndp","en","sap"] );
+ t( "Sibling Axis", "//p/../*", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","sndp","en","sap"] );
+ t( "Has Children", "//p[a]", ["firstp","ap","en","sap"] );
+});
+
+test("val()", function() {
+ expect(2);
+ ok( $("#text1").val() == "Test", "Check for value of input element" );
+ ok( !$("#text1").val() == "", "Check for value of input element" );
+});
+
+test("val(String)", function() {
+ expect(2);
+ document.getElementById('text1').value = "bla";
+ ok( $("#text1").val() == "bla", "Check for modified value of input element" );
+ $("#text1").val('test');
+ ok ( document.getElementById('text1').value == "test", "Check for modified (via val(String)) value of input element" );
+});
+
+test("html(String)", function() {
+ expect(1);
+ var div = $("div");
+ div.html("<b>test</b>");
+ var pass = true;
+ for ( var i = 0; i < div.size(); i++ ) {
+ if ( div.get(i).childNodes.length == 0 ) pass = false;
+ }
+ ok( pass, "Set HTML" );
+});
+
+test("id()", function() {
+ expect(3);
+ ok( $(document.getElementById('main')).id() == "main", "Check for id" );
+ ok( $("#foo").id() == "foo", "Check for id" );
+ ok( !$("head").id(), "Check for id" );
+});
+
+test("title()", function() {
+ expect(2);
+ ok( $(document.getElementById('google')).title() == "Google!", "Check for title" );
+ ok( !$("#yahoo").title(), "Check for title" );
+});
+
+test("name()", function() {
+ expect(3);
+ ok( $(document.getElementById('text1')).name() == "action", "Check for name" );
+ ok( $("#hidden1").name() == "hidden", "Check for name" );
+ ok( !$("#area1").name(), "Check for name" );
+});
+
+
+test("siblings([String])", function() {
+ expect(3);
+ isSet( $("#en").siblings().get(), q("sndp", "sap"), "Check for siblings" );
+ isSet( $("#sndp").siblings("[code]").get(), q("sap"), "Check for filtered siblings (has code child element)" );
+ isSet( $("#sndp").siblings("[a]").get(), q("en", "sap"), "Check for filtered siblings (has anchor child element)" );
+});
+
+test("children([String])", function() {
+ expect(2);
+ isSet( $("#foo").children().get(), q("sndp", "en", "sap"), "Check for children" );
+ isSet( $("#foo").children("[code]").get(), q("sndp", "sap"), "Check for filtered children" );
+});
+
+
+test("show()", function() {
+ expect(1);
+ var pass = true, div = $("div");
+ div.show().each(function(){
+ if ( this.style.display == "none" ) pass = false;
+ });
+ ok( pass, "Show" );
+});
+
+test("addClass(String)", function() {
+ var div = $("div");
+ div.addClass("test");
+ var pass = true;
+ for ( var i = 0; i < div.size(); i++ ) {
+ if ( div.get(i).className.indexOf("test") == -1 ) pass = false;
+ }
+ ok( pass, "Add Class" );
+});
+
+test("removeClass(String) - simple", function() {
+ expect(1);
+ var div = $("div").addClass("test").removeClass("test"),
+ pass = true;
+ for ( var i = 0; i < div.size(); i++ ) {
+ if ( div.get(i).className.indexOf("test") != -1 ) pass = false;
+ }
+ ok( pass, "Remove Class" );
+});
+
+test("removeClass(String) - add three classes and remove again", function() {
+ expect(1);
+ var div = $("div").addClass("test").addClass("foo").addClass("bar");
+ div.removeClass("test").removeClass("bar").removeClass("foo");
+ var pass = true;
+ for ( var i = 0; i < div.size(); i++ ) {
+ if ( div.get(i).className.match(/test|bar|foo/) ) pass = false;
+ }
+ ok( pass, "Remove multiple classes" );
+}); \ No newline at end of file
diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js
index 44eedf252..f2e9c1816 100644
--- a/src/jquery/jquery.js
+++ b/src/jquery/jquery.js
@@ -15,14 +15,6 @@ window.undefined = window.undefined;
/**
* Create a new jQuery Object
*
- * @test ok( Array.prototype.push, "Array.push()" );
- * ok( Function.prototype.apply, "Function.apply()" );
- * ok( document.getElementById, "getElementById" );
- * ok( document.getElementsByTagName, "getElementsByTagName" );
- * ok( RegExp, "RegExp" );
- * ok( jQuery, "jQuery" );
- * ok( $, "$()" );
- *
* @constructor
* @private
* @name jQuery
@@ -211,8 +203,6 @@ jQuery.fn = jQuery.prototype = {
* @before <img src="test1.jpg"/> <img src="test2.jpg"/>
* @result 2
*
- * @test ok( $("div").length == 2, "Get Number of Elements Found" );
- *
* @property
* @name length
* @type Number
@@ -226,8 +216,6 @@ jQuery.fn = jQuery.prototype = {
* @before <img src="test1.jpg"/> <img src="test2.jpg"/>
* @result 2
*
- * @test ok( $("div").size() == 2, "Get Number of Elements Found" );
- *
* @name size
* @type Number
* @cat Core
@@ -245,8 +233,6 @@ jQuery.fn = jQuery.prototype = {
* @before <img src="test1.jpg"/> <img src="test2.jpg"/>
* @result [ <img src="test1.jpg"/> <img src="test2.jpg"/> ]
*
- * @test isSet( $("div").get(), q("main","foo"), "Get All Elements" );
- *
* @name get
* @type Array<Element>
* @cat Core
@@ -260,8 +246,6 @@ jQuery.fn = jQuery.prototype = {
* @before <img src="test1.jpg"/> <img src="test2.jpg"/>
* @result [ <img src="test1.jpg"/> ]
*
- * @test ok( $("div").get(0) == document.getElementById("main"), "Get A Single Element" );
- *
* @name get
* @type Element
* @param Number num Access the element in the Nth position.
@@ -322,14 +306,6 @@ jQuery.fn = jQuery.prototype = {
* @before <img/> <img/>
* @result <img src="test.jpg"/> <img src="test.jpg"/>
*
- * @test var div = $("div");
- * div.each(function(){this.foo = 'zoo';});
- * var pass = true;
- * for ( var i = 0; i < div.size(); i++ ) {
- * if ( div.get(i).foo != "zoo" ) pass = false;
- * }
- * ok( pass, "Execute a function, Relative" );
- *
* @name each
* @type jQuery
* @param Function fn A function to execute
@@ -356,16 +332,6 @@ jQuery.fn = jQuery.prototype = {
* @before <div id="foobar"></div><b></b><span id="foo"></span>
* @result -1
*
- * @test ok( $([window, document]).index(window) == 0, "Check for index of elements" );
- * ok( $([window, document]).index(document) == 1, "Check for index of elements" );
- * var inputElements = $('#radio1,#radio2,#check1,#check2');
- * ok( inputElements.index(document.getElementById('radio1')) == 0, "Check for index of elements" );
- * ok( inputElements.index(document.getElementById('radio2')) == 1, "Check for index of elements" );
- * ok( inputElements.index(document.getElementById('check1')) == 2, "Check for index of elements" );
- * ok( inputElements.index(document.getElementById('check2')) == 3, "Check for index of elements" );
- * ok( inputElements.index(window) == -1, "Check for not found index" );
- * ok( inputElements.index(document) == -1, "Check for not found index" );
- *
* @name index
* @type Number
* @param Object obj Object to search for
@@ -388,19 +354,6 @@ jQuery.fn = jQuery.prototype = {
* @before <img src="test.jpg"/>
* @result test.jpg
*
- * @test ok( $('#text1').attr('value') == "Test", 'Check for value attribute' );
- * ok( $('#text1').attr('type') == "text", 'Check for type attribute' );
- * ok( $('#radio1').attr('type') == "radio", 'Check for type attribute' );
- * ok( $('#check1').attr('type') == "checkbox", 'Check for type attribute' );
- * ok( $('#simon1').attr('rel') == "bookmark", 'Check for rel attribute' );
- * ok( $('#google').attr('title') == "Google!", 'Check for title attribute' );
- * ok( $('#mark').attr('hreflang') == "en", 'Check for hreflang attribute' );
- * ok( $('#en').attr('lang') == "en", 'Check for lang attribute' );
- * ok( $('#simon').attr('class') == "blog link", 'Check for class attribute' );
- * ok( $('#name').attr('name') == "name", 'Check for name attribute' );
- * ok( $('#text1').attr('name') == "action", 'Check for name attribute' );
- * ok( $('#form').attr('action').indexOf("formaction") >= 0, 'Check for action attribute' );
- *
* @name attr
* @type Object
* @param String name The name of the property to access.
@@ -416,12 +369,6 @@ jQuery.fn = jQuery.prototype = {
* @before <img/>
* @result <img src="test.jpg" alt="Test Image"/>
*
- * @test var pass = true;
- * $("div").attr({foo: 'baz', zoo: 'ping'}).each(function(){
- * if ( this.getAttribute('foo') != "baz" && this.getAttribute('zoo') != "ping" ) pass = false;
- * });
- * ok( pass, "Set Multiple Attributes" );
- *
* @name attr
* @type jQuery
* @param Hash prop A set of key/value pairs to set as object properties.
@@ -435,36 +382,6 @@ jQuery.fn = jQuery.prototype = {
* @before <img/>
* @result <img src="test.jpg"/>
*
- * @test var div = $("div");
- * div.attr("foo", "bar");
- * var pass = true;
- * for ( var i = 0; i < div.size(); i++ ) {
- * if ( div.get(i).getAttribute('foo') != "bar" ) pass = false;
- * }
- * ok( pass, "Set Attribute" );
- *
- * $("#name").attr('name', 'something');
- * ok( $("#name").name() == 'something', 'Set name attribute' );
- * $("#check2").attr('checked', true);
- * ok( document.getElementById('check2').checked == true, 'Set checked attribute' );
- * $("#check2").attr('checked', false);
- * ok( document.getElementById('check2').checked == false, 'Set checked attribute' );
- * $("#text1").attr('readonly', true);
- * ok( document.getElementById('text1').readOnly == true, 'Set readonly attribute' );
- * $("#text1").attr('readonly', false);
- * ok( document.getElementById('text1').readOnly == false, 'Set readonly attribute' );
- *
- * @test stop();
- * $.get('data/dashboard.xml', function(xml) {
- * var titles = [];
- * $('tab', xml).each(function() {
- * titles.push($(this).attr('title'));
- * });
- * ok( titles[0] == 'Location', 'attr() in XML context: Check first title' );
- * ok( titles[1] == 'Users', 'attr() in XML context: Check second title' );
- * start();
- * });
- *
* @name attr
* @type jQuery
* @param String key The name of the property to set.
@@ -516,8 +433,6 @@ jQuery.fn = jQuery.prototype = {
* representation of itself. Eg. fontWeight, fontSize, fontFamily, borderWidth,
* borderStyle, borderBottomWidth etc.
*
- * @test ok( $('#main').css("display") == 'none', 'Check for css property "display"');
- *
* @name css
* @type Object
* @param String name The name of the property to access.
@@ -533,20 +448,6 @@ jQuery.fn = jQuery.prototype = {
* @before <p>Test Paragraph.</p>
* @result <p style="color:red; background:blue;">Test Paragraph.</p>
*
- * @test ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible');
- * $('#foo').css({display: 'none'});
- * ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');
- * $('#foo').css({display: 'block'});
- * ok( $('#foo').is(':visible'), 'Modified CSS display: Assert element is visible');
- * $('#floatTest').css({styleFloat: 'right'});
- * ok( $('#floatTest').css('styleFloat') == 'right', 'Modified CSS float using "styleFloat": Assert float is right');
- * $('#floatTest').css({cssFloat: 'left'});
- * ok( $('#floatTest').css('cssFloat') == 'left', 'Modified CSS float using "cssFloat": Assert float is left');
- * $('#floatTest').css({'float': 'right'});
- * ok( $('#floatTest').css('float') == 'right', 'Modified CSS float using "float": Assert float is right');
- * $('#floatTest').css({'font-size': '30px'});
- * ok( $('#floatTest').css('font-size') == '30px', 'Modified CSS font-size: Assert font-size is 30px');
- *
* @name css
* @type jQuery
* @param Hash prop A set of key/value pairs to set as style properties.
@@ -561,21 +462,6 @@ jQuery.fn = jQuery.prototype = {
* @result <p style="color:red;">Test Paragraph.</p>
* @desc Changes the color of all paragraphs to red
*
- *
- * @test ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible');
- * $('#foo').css('display', 'none');
- * ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');
- * $('#foo').css('display', 'block');
- * ok( $('#foo').is(':visible'), 'Modified CSS display: Assert element is visible');
- * $('#floatTest').css('styleFloat', 'left');
- * ok( $('#floatTest').css('styleFloat') == 'left', 'Modified CSS float using "styleFloat": Assert float is left');
- * $('#floatTest').css('cssFloat', 'right');
- * ok( $('#floatTest').css('cssFloat') == 'right', 'Modified CSS float using "cssFloat": Assert float is right');
- * $('#floatTest').css('float', 'left');
- * ok( $('#floatTest').css('float') == 'left', 'Modified CSS float using "float": Assert float is left');
- * $('#floatTest').css('font-size', '20px');
- * ok( $('#floatTest').css('font-size') == '20px', 'Modified CSS font-size: Assert font-size is 20px');
- *
* @name css
* @type jQuery
* @param String key The name of the property to set.
@@ -595,9 +481,6 @@ jQuery.fn = jQuery.prototype = {
* @before <p>Test Paragraph.</p>
* @result Test Paragraph.
*
- * @test var expected = "This link has class=\"blog\": Simon Willison's Weblog";
- * ok( $('#sap').text() == expected, 'Check for merged text of more then one element.' );
- *
* @name text
* @type String
* @cat DOM
@@ -633,11 +516,6 @@ jQuery.fn = jQuery.prototype = {
* @before <p>Test Paragraph.</p>
* @result <div class='wrap'><p>Test Paragraph.</p></div>
*
- * @test var defaultText = 'Try them out:'
- * var result = $('#first').wrap('<div class="red"><span></span></div>').text();
- * ok( defaultText == result, 'Check for wrapping of on-the-fly html' );
- * ok( $('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
- *
* @name wrap
* @type jQuery
* @param String html A string of HTML, that will be created on the fly and wrapped around the target.
@@ -661,11 +539,6 @@ jQuery.fn = jQuery.prototype = {
* @before <p>Test Paragraph.</p><div id="content"></div>
* @result <div id="content"><p>Test Paragraph.</p></div>
*
- * @test var defaultText = 'Try them out:'
- * var result = $('#first').wrap(document.getElementById('empty')).parent();
- * ok( result.is('ol'), 'Check for element wrapping' );
- * ok( result.text() == defaultText, 'Check for element wrapping' );
- *
* @name wrap
* @type jQuery
* @param Element elem A DOM element that will be wrapped.
@@ -702,11 +575,6 @@ jQuery.fn = jQuery.prototype = {
* @before <p>I would like to say: </p>
* @result <p>I would like to say: <b>Hello</b></p>
*
- * @test var defaultText = 'Try them out:'
- * var result = $('#first').append('<b>buga</b>');
- * ok( result.text() == defaultText + 'buga', 'Check if text appending works' );
- * ok( $('#select3').append('<option value="appendTest">Append Test</option>').find('option:last-child').attr('value') == 'appendTest', 'Appending html options to select element');
- *
* @name append
* @type jQuery
* @param String html A string of HTML, that will be created on the fly and appended to the target.
@@ -722,10 +590,6 @@ jQuery.fn = jQuery.prototype = {
* @before <p>I would like to say: </p><b id="foo">Hello</b>
* @result <p>I would like to say: <b id="foo">Hello</b></p>
*
- * @test var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
- * $('#sap').append(document.getElementById('first'));
- * ok( expected == $('#sap').text(), "Check for appending of element" );
- *
* @name append
* @type jQuery
* @param Element elem A DOM element that will be appended.
@@ -741,10 +605,6 @@ jQuery.fn = jQuery.prototype = {
* @before <p>I would like to say: </p><b>Hello</b>
* @result <p>I would like to say: <b>Hello</b></p>
*
- * @test var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
- * $('#sap').append([document.getElementById('first'), document.getElementById('yahoo')]);
- * ok( expected == $('#sap').text(), "Check for appending of array of elements" );
- *
* @name append
* @type jQuery
* @param Array<Element> elems An array of elements, all of which will be appended.
@@ -766,11 +626,6 @@ jQuery.fn = jQuery.prototype = {
* @before <p>I would like to say: </p>
* @result <p><b>Hello</b>I would like to say: </p>
*
- * @test var defaultText = 'Try them out:'
- * var result = $('#first').prepend('<b>buga</b>');
- * ok( result.text() == 'buga' + defaultText, 'Check if text prepending works' );
- * ok( $('#select3').prepend('<option value="prependTest">Prepend Test</option>').find('option:first-child').attr('value') == 'prependTest', 'Prepending html options to select element');
- *
* @name prepend
* @type jQuery
* @param String html A string of HTML, that will be created on the fly and appended to the target.
@@ -786,10 +641,6 @@ jQuery.fn = jQuery.prototype = {
* @before <p>I would like to say: </p><b id="foo">Hello</b>
* @result <p><b id="foo">Hello</b>I would like to say: </p>
*
- * @test var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
- * $('#sap').prepend(document.getElementById('first'));
- * ok( expected == $('#sap').text(), "Check for prepending of element" );
- *
* @name prepend
* @type jQuery
* @param Element elem A DOM element that will be appended.
@@ -805,10 +656,6 @@ jQuery.fn = jQuery.prototype = {
* @before <p>I would like to say: </p><b>Hello</b>
* @result <p><b>Hello</b>I would like to say: </p>
*
- * @test var expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
- * $('#sap').prepend([document.getElementById('first'), document.getElementById('yahoo')]);
- * ok( expected == $('#sap').text(), "Check for prepending of array of elements" );
- *
* @name prepend
* @type jQuery
* @param Array<Element> elems An array of elements, all of which will be appended.
@@ -828,10 +675,6 @@ jQuery.fn = jQuery.prototype = {
* @before <p>I would like to say: </p>
* @result <b>Hello</b><p>I would like to say: </p>
*
- * @test var expected = 'This is a normal link: bugaYahoo';
- * $('#yahoo').before('<b>buga</b>');
- * ok( expected == $('#en').text(), 'Insert String before' );
- *
* @name before
* @type jQuery
* @param String html A string of HTML, that will be created on the fly and appended to the target.
@@ -845,10 +688,6 @@ jQuery.fn = jQuery.prototype = {
* @before <p>I would like to say: </p><b id="foo">Hello</b>
* @result <b id="foo">Hello</b><p>I would like to say: </p>
*
- * @test var expected = "This is a normal link: Try them out:Yahoo";
- * $('#yahoo').before(document.getElementById('first'));
- * ok( expected == $('#en').text(), "Insert element before" );
- *
* @name before
* @type jQuery
* @param Element elem A DOM element that will be appended.
@@ -862,10 +701,6 @@ jQuery.fn = jQuery.prototype = {
* @before <p>I would like to say: </p><b>Hello</b>
* @result <b>Hello</b><p>I would like to say: </p>
*
- * @test var expected = "This is a normal link: Try them out:diveintomarkYahoo";
- * $('#yahoo').before([document.getElementById('first'), document.getElementById('mark')]);
- * ok( expected == $('#en').text(), "Insert array of elements before" );
- *
* @name before
* @type jQuery
* @param Array<Element> elems An array of elements, all of which will be appended.
@@ -885,10 +720,6 @@ jQuery.fn = jQuery.prototype = {
* @before <p>I would like to say: </p>
* @result <p>I would like to say: </p><b>Hello</b>
*
- * @test var expected = 'This is a normal link: Yahoobuga';
- * $('#yahoo').after('<b>buga</b>');
- * ok( expected == $('#en').text(), 'Insert String after' );
- *
* @name after
* @type jQuery
* @param String html A string of HTML, that will be created on the fly and appended to the target.
@@ -902,10 +733,6 @@ jQuery.fn = jQuery.prototype = {
* @before <b id="foo">Hello</b><p>I would like to say: </p>
* @result <p>I would like to say: </p><b id="foo">Hello</b>
*
- * @test var expected = "This is a normal link: YahooTry them out:";
- * $('#yahoo').after(document.getElementById('first'));
- * ok( expected == $('#en').text(), "Insert element after" );
- *
* @name after
* @type jQuery
* @param Element elem A DOM element that will be appended.
@@ -919,10 +746,6 @@ jQuery.fn = jQuery.prototype = {
* @before <b>Hello</b><p>I would like to say: </p>
* @result <p>I would like to say: </p><b>Hello</b>
*
- * @test var expected = "This is a normal link: YahooTry them out:diveintomark";
- * $('#yahoo').after([document.getElementById('first'), document.getElementById('mark')]);
- * ok( expected == $('#en').text(), "Insert array of elements after" );
- *
* @name after
* @type jQuery
* @param Array<Element> elems An array of elements, all of which will be appended.
@@ -943,9 +766,6 @@ jQuery.fn = jQuery.prototype = {
* @before <p><span>Hello</span>, how are you?</p>
* @result $("p").find("span").end() == [ <p>...</p> ]
*
- * @test ok( 'Yahoo' == $('#yahoo').parent().end().text(), 'Check for end' );
- * ok( $('#yahoo').end(), 'Check for end with nothing to end' );
- *
* @name end
* @type jQuery
* @cat DOM/Traversing
@@ -968,8 +788,6 @@ jQuery.fn = jQuery.prototype = {
* @before <p><span>Hello</span>, how are you?</p>
* @result $("p").find("span") == [ <span>Hello</span> ]
*
- * @test ok( 'Yahoo' == $('#foo').find('.blogTest').text(), 'Check for find' );
- *
* @name find
* @type jQuery
* @param String expr An expression to search with.
@@ -992,11 +810,6 @@ jQuery.fn = jQuery.prototype = {
* @before <b>Hello</b><p>, how are you?</p>
* @result <b>Hello</b><p><b>Hello</b>, how are you?</p>
*
- * @test ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Assert text for #en' );
- * var clone = $('#yahoo').clone();
- * ok( 'Try them out:Yahoo' == $('#first').append(clone).text(), 'Check for clone' );
- * ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Reassert text for #en' );
- *
* @name clone
* @type jQuery
* @cat DOM/Manipulation
@@ -1019,14 +832,6 @@ jQuery.fn = jQuery.prototype = {
* @before <p class="selected">Hello</p><p>How are you?</p>
* @result $("p").filter(".selected") == [ <p class="selected">Hello</p> ]
*
- * @test isSet( $("input").filter(":checked").get(), q("radio2", "check1"), "Filter elements" );
- * @test $("input").filter(":checked",function(i){
- * ok( this == q("radio2", "check1")[i], "Filter elements, context" );
- * });
- * @test $("#main > p#ap > a").filter("#foobar",function(){},function(i){
- * ok( this == q("google","groups", "mark")[i], "Filter elements, else context" );
- * });
- *
* @name filter
* @type jQuery
* @param String expr An expression to search with.
@@ -1093,8 +898,6 @@ jQuery.fn = jQuery.prototype = {
* @before <p>Hello</p><p id="selected">Hello Again</p>
* @result [ <p>Hello</p> ]
*
- * @test ok($("#main > p#ap > a").not("#google").length == 2, ".not")
- *
* @name not
* @type jQuery
* @param String expr An expression with which to remove matching elements
@@ -1172,29 +975,6 @@ jQuery.fn = jQuery.prototype = {
* @result false
* @desc An invalid expression always returns false.
*
- * @test ok( $('#form').is('form'), 'Check for element: A form must be a form' );
- * ok( !$('#form').is('div'), 'Check for element: A form is not a div' );
- * ok( $('#mark').is('.blog'), 'Check for class: Expected class "blog"' );
- * ok( !$('#mark').is('.link'), 'Check for class: Did not expect class "link"' );
- * ok( $('#simon').is('.blog.link'), 'Check for multiple classes: Expected classes "blog" and "link"' );
- * ok( !$('#simon').is('.blogTest'), 'Check for multiple classes: Expected classes "blog" and "link", but not "blogTest"' );
- * ok( $('#en').is('[@lang="en"]'), 'Check for attribute: Expected attribute lang to be "en"' );
- * ok( !$('#en').is('[@lang="de"]'), 'Check for attribute: Expected attribute lang to be "en", not "de"' );
- * ok( $('#text1').is('[@type="text"]'), 'Check for attribute: Expected attribute type to be "text"' );
- * ok( !$('#text1').is('[@type="radio"]'), 'Check for attribute: Expected attribute type to be "text", not "radio"' );
- * ok( $('#text2').is(':disabled'), 'Check for pseudoclass: Expected to be disabled' );
- * ok( !$('#text1').is(':disabled'), 'Check for pseudoclass: Expected not disabled' );
- * ok( $('#radio2').is(':checked'), 'Check for pseudoclass: Expected to be checked' );
- * ok( !$('#radio1').is(':checked'), 'Check for pseudoclass: Expected not checked' );
- * ok( $('#foo').is('[p]'), 'Check for child: Expected a child "p" element' );
- * ok( !$('#foo').is('[ul]'), 'Check for child: Did not expect "ul" element' );
- * ok( $('#foo').is('[p][a][code]'), 'Check for childs: Expected "p", "a" and "code" child elements' );
- * ok( !$('#foo').is('[p][a][code][ol]'), 'Check for childs: Expected "p", "a" and "code" child elements, but no "ol"' );
- * ok( !$('#foo').is(0), 'Expected false for an invalid expression - 0' );
- * ok( !$('#foo').is(null), 'Expected false for an invalid expression - null' );
- * ok( !$('#foo').is(''), 'Expected false for an invalid expression - ""' );
- * ok( !$('#foo').is(undefined), 'Expected false for an invalid expression - undefined' );
- *
* @name is
* @type Boolean
* @param String expr The expression with which to filter
@@ -1307,14 +1087,6 @@ jQuery.fn = jQuery.prototype = {
* jQuery.extend(settings, options);
* @result settings == { validate: true, limit: 5, name: "bar" }
*
- * @test var settings = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" };
- * var options = { xnumber2: 1, xstring2: "x", xxx: "newstring" };
- * var optionsCopy = { xnumber2: 1, xstring2: "x", xxx: "newstring" };
- * var merged = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "x", xxx: "newstring" };
- * jQuery.extend(settings, options);
- * isSet( settings, merged, "Check if extended: settings must be extended" );
- * isSet ( options, optionsCopy, "Check if not modified: options must not be modified" );
- *
* @name $.extend
* @param Object obj The object to extend
* @param Object prop The object that will be merged into the first.
@@ -1654,112 +1426,6 @@ jQuery.extend({
],
/**
- *
- * @test t( "Element Selector", "div", ["main","foo"] );
- * t( "Element Selector", "body", ["body"] );
- * t( "Element Selector", "html", ["html"] );
- * ok( $("*").size() >= 30, "Element Selector" );
- * t( "Parent Element", "div div", ["foo"] );
- *
- * t( "ID Selector", "#body", ["body"] );
- * t( "ID Selector w/ Element", "body#body", ["body"] );
- * t( "ID Selector w/ Element", "ul#first", [] );
- *
- * t( "Class Selector", ".blog", ["mark","simon"] );
- * t( "Class Selector", ".blog.link", ["simon"] );
- * t( "Class Selector w/ Element", "a.blog", ["mark","simon"] );
- * t( "Parent Class Selector", "p .blog", ["mark","simon"] );
- *
- * t( "Comma Support", "a.blog, div", ["mark","simon","main","foo"] );
- * t( "Comma Support", "a.blog , div", ["mark","simon","main","foo"] );
- * t( "Comma Support", "a.blog ,div", ["mark","simon","main","foo"] );
- * t( "Comma Support", "a.blog,div", ["mark","simon","main","foo"] );
- *
- * t( "Child", "p > a", ["simon1","google","groups","mark","yahoo","simon"] );
- * t( "Child", "p> a", ["simon1","google","groups","mark","yahoo","simon"] );
- * t( "Child", "p >a", ["simon1","google","groups","mark","yahoo","simon"] );
- * t( "Child", "p>a", ["simon1","google","groups","mark","yahoo","simon"] );
- * t( "Child w/ Class", "p > a.blog", ["mark","simon"] );
- * t( "All Children", "code > *", ["anchor1","anchor2"] );
- * t( "All Grandchildren", "p > * > *", ["anchor1","anchor2"] );
- * t( "Adjacent", "a + a", ["groups"] );
- * t( "Adjacent", "a +a", ["groups"] );
- * t( "Adjacent", "a+ a", ["groups"] );
- * t( "Adjacent", "a+a", ["groups"] );
- * t( "Adjacent", "p + p", ["ap","en","sap"] );
- * t( "Comma, Child, and Adjacent", "a + a, code > a", ["groups","anchor1","anchor2"] );
- * t( "First Child", "p:first-child", ["firstp","sndp"] );
- * t( "Attribute Exists", "a[@title]", ["google"] );
- * t( "Attribute Exists", "*[@title]", ["google"] );
- * t( "Attribute Exists", "[@title]", ["google"] );
- *
- * t( "Attribute Equals", "a[@rel='bookmark']", ["simon1"] );
- * t( "Attribute Equals", 'a[@rel="bookmark"]', ["simon1"] );
- * t( "Attribute Equals", "a[@rel=bookmark]", ["simon1"] );
- * t( "Multiple Attribute Equals", "input[@type='hidden'],input[@type='radio']", ["hidden1","radio1","radio2"] );
- * t( "Multiple Attribute Equals", "input[@type=\"hidden\"],input[@type='radio']", ["hidden1","radio1","radio2"] );
- * t( "Multiple Attribute Equals", "input[@type=hidden],input[@type=radio]", ["hidden1","radio1","radio2"] );
- *
- * t( "Attribute Begins With", "a[@href ^= 'http://www']", ["google","yahoo"] );
- * t( "Attribute Ends With", "a[@href $= 'org/']", ["mark"] );
- * t( "Attribute Contains", "a[@href *= 'google']", ["google","groups"] );
- * t( "First Child", "p:first-child", ["firstp","sndp"] );
- * t( "Last Child", "p:last-child", ["sap"] );
- * t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2"] );
- * t( "Empty", "ul:empty", ["firstUL"] );
- * t( "Enabled UI Element", "input:enabled", ["text1","radio1","radio2","check1","check2","hidden1","hidden2","name"] );
- * t( "Disabled UI Element", "input:disabled", ["text2"] );
- * t( "Checked UI Element", "input:checked", ["radio2","check1"] );
- * t( "Selected Option Element", "option:selected", ["option1a","option2d","option3b","option3c"] );
- * t( "Text Contains", "a:contains('Google')", ["google","groups"] );
- * t( "Text Contains", "a:contains('Google Groups')", ["groups"] );
- * t( "Element Preceded By", "p ~ div", ["foo"] );
- * t( "Not", "a.blog:not(.link)", ["mark"] );
- *
- * ok( jQuery.find("//*").length >= 30, "All Elements (//*)" );
- * t( "All Div Elements", "//div", ["main","foo"] );
- * t( "Absolute Path", "/html/body", ["body"] );
- * t( "Absolute Path w/ *", "/* /body", ["body"] );
- * t( "Long Absolute Path", "/html/body/dl/div/div/p", ["sndp","en","sap"] );
- * t( "Absolute and Relative Paths", "/html//div", ["main","foo"] );
- * t( "All Children, Explicit", "//code/*", ["anchor1","anchor2"] );
- * t( "All Children, Implicit", "//code/", ["anchor1","anchor2"] );
- * t( "Attribute Exists", "//a[@title]", ["google"] );
- * t( "Attribute Equals", "//a[@rel='bookmark']", ["simon1"] );
- * t( "Parent Axis", "//p/..", ["main","foo"] );
- * t( "Sibling Axis", "//p/../", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","sndp","en","sap"] );
- * t( "Sibling Axis", "//p/../*", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","sndp","en","sap"] );
- * t( "Has Children", "//p[a]", ["firstp","ap","en","sap"] );
- *
- * t( "nth Element", "p:nth(1)", ["ap"] );
- * t( "First Element", "p:first", ["firstp"] );
- * t( "Last Element", "p:last", ["first"] );
- * t( "Even Elements", "p:even", ["firstp","sndp","sap"] );
- * t( "Odd Elements", "p:odd", ["ap","en","first"] );
- * t( "Position Equals", "p:eq(1)", ["ap"] );
- * t( "Position Greater Than", "p:gt(0)", ["ap","sndp","en","sap","first"] );
- * t( "Position Less Than", "p:lt(3)", ["firstp","ap","sndp"] );
- * t( "Is A Parent", "p:parent", ["firstp","ap","sndp","en","sap","first"] );
- * t( "Is Visible", "input:visible", ["text1","text2","radio1","radio2","check1","check2","name"] );
- * t( "Is Hidden", "input:hidden", ["hidden1","hidden2"] );
- *
- * t( "Grouped Form Elements", "input[@name='foo[bar]']", ["hidden2"] );
- *
- * t( "All Children of ID", "#foo/*", ["sndp", "en", "sap"] );
- * t( "All Children of ID with no children", "#firstUL/*", [] );
- *
- * t( "Form element :input", ":input", ["text1", "text2", "radio1", "radio2", "check1", "check2", "hidden1", "hidden2", "name", "button", "area1", "select1", "select2", "select3"] );
- * t( "Form element :radio", ":radio", ["radio1", "radio2"] );
- * t( "Form element :checkbox", ":checkbox", ["check1", "check2"] );
- * t( "Form element :text", ":text", ["text1", "text2", "hidden2", "name"] );
- * t( "Form element :radio:checked", ":radio:checked", ["radio2"] );
- * t( "Form element :checkbox:checked", ":checkbox:checked", ["check1"] );
- * t( "Form element :checkbox:checked, :radio:checked", ":checkbox:checked, :radio:checked", ["check1", "radio2"] );
- *
- * t( ":not() Existing attribute", "select:not([@multiple])", ["select1", "select2"]);
- * t( ":not() Equals attribute", "select:not([@name=select1])", ["select2", "select3"]);
- * t( ":not() Equals quoted attribute", "select:not([@name='select1'])", ["select2", "select3"]);
- *
* @name $.find
* @type Array<Element>
* @private
@@ -2728,9 +2394,6 @@ jQuery.macros = {
* @before <input type="text" value="some text"/>
* @result "some text"
*
- * @test ok( $("#text1").val() == "Test", "Check for value of input element" );
- * ok( !$("#text1").val() == "", "Check for value of input element" );
- *
* @name val
* @type String
* @cat DOM/Attributes
@@ -2743,11 +2406,6 @@ jQuery.macros = {
* @before <input type="text" value="some text"/>
* @result <input type="text" value="test"/>
*
- * @test document.getElementById('text1').value = "bla";
- * ok( $("#text1").val() == "bla", "Check for modified value of input element" );
- * $("#text1").val('test');
- * ok ( document.getElementById('text1').value == "test", "Check for modified (via val(String)) value of input element" );
- *
* @name val
* @type jQuery
* @param String val Set the property to the specified value.
@@ -2774,14 +2432,6 @@ jQuery.macros = {
* @before <div><input/></div>
* @result <div><b>new stuff</b></div>
*
- * @test var div = $("div");
- * div.html("<b>test</b>");
- * var pass = true;
- * for ( var i = 0; i < div.size(); i++ ) {
- * if ( div.get(i).childNodes.length == 0 ) pass = false;
- * }
- * ok( pass, "Set HTML" );
- *
* @name html
* @type jQuery
* @param String val Set the html contents to the specified value.
@@ -2796,10 +2446,6 @@ jQuery.macros = {
* @before <input type="text" id="test" value="some text"/>
* @result "test"
*
- * @test ok( $(document.getElementById('main')).id() == "main", "Check for id" );
- * ok( $("#foo").id() == "foo", "Check for id" );
- * ok( !$("head").id(), "Check for id" );
- *
* @name id
* @type String
* @cat DOM/Attributes
@@ -2826,9 +2472,6 @@ jQuery.macros = {
* @before <img src="test.jpg" title="my image"/>
* @result "my image"
*
- * @test ok( $(document.getElementById('google')).title() == "Google!", "Check for title" );
- * ok( !$("#yahoo").title(), "Check for title" );
- *
* @name title
* @type String
* @cat DOM/Attributes
@@ -2855,10 +2498,6 @@ jQuery.macros = {
* @before <input type="text" name="username"/>
* @result "username"
*
- * @test ok( $(document.getElementById('text1')).name() == "action", "Check for name" );
- * ok( $("#hidden1").name() == "hidden", "Check for name" );
- * ok( !$("#area1").name(), "Check for name" );
- *
* @name name
* @type String
* @cat DOM/Attributes
@@ -3114,8 +2753,6 @@ jQuery.macros = {
* @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
* @result [ <p>Hello</p>, <p>And Again</p> ]
*
- * @test isSet( $("#en").siblings().get(), q("sndp", "sap"), "Check for siblings" );
- *
* @name siblings
* @type jQuery
* @cat DOM/Traversing
@@ -3129,9 +2766,6 @@ jQuery.macros = {
* @before <div><span>Hello</span></div><p class="selected">Hello Again</p><p>And Again</p>
* @result [ <p class="selected">Hello Again</p> ]
*
- * @test isSet( $("#sndp").siblings("[code]").get(), q("sap"), "Check for filtered siblings (has code child element)" );
- * isSet( $("#sndp").siblings("[a]").get(), q("en", "sap"), "Check for filtered siblings (has anchor child element)" );
- *
* @name siblings
* @type jQuery
* @param String expr An expression to filter the sibling Elements with
@@ -3148,8 +2782,6 @@ jQuery.macros = {
* @before <p>Hello</p><div><span>Hello Again</span></div><p>And Again</p>
* @result [ <span>Hello Again</span> ]
*
- * @test isSet( $("#foo").children().get(), q("sndp", "en", "sap"), "Check for children" );
- *
* @name children
* @type jQuery
* @cat DOM/Traversing
@@ -3163,8 +2795,6 @@ jQuery.macros = {
* @before <div><span>Hello</span><p class="selected">Hello Again</p><p>And Again</p></div>
* @result [ <p class="selected">Hello Again</p> ]
*
- * @test isSet( $("#foo").children("[code]").get(), q("sndp", "sap"), "Check for filtered children" );
- *
* @name children
* @type jQuery
* @param String expr An expression to filter the child Elements with
@@ -3198,12 +2828,6 @@ jQuery.macros = {
* @before <p style="display: none">Hello</p>
* @result [ <p style="display: block">Hello</p> ]
*
- * @test var pass = true, div = $("div");
- * div.show().each(function(){
- * if ( this.style.display == "none" ) pass = false;
- * });
- * ok( pass, "Show" );
- *
* @name show
* @type jQuery
* @cat Effects
@@ -3262,14 +2886,6 @@ jQuery.macros = {
* @before <p>Hello</p>
* @result [ <p class="selected">Hello</p> ]
*
- * @test var div = $("div");
- * div.addClass("test");
- * var pass = true;
- * for ( var i = 0; i < div.size(); i++ ) {
- * if ( div.get(i).className.indexOf("test") == -1 ) pass = false;
- * }
- * ok( pass, "Add Class" );
- *
* @name addClass
* @type jQuery
* @param String class A CSS class to add to the elements
@@ -3286,24 +2902,6 @@ jQuery.macros = {
* @before <p class="selected">Hello</p>
* @result [ <p>Hello</p> ]
*
- * @test var div = $("div").addClass("test");
- * div.removeClass("test");
- * var pass = true;
- * for ( var i = 0; i < div.size(); i++ ) {
- * if ( div.get(i).className.indexOf("test") != -1 ) pass = false;
- * }
- * ok( pass, "Remove Class" );
- *
- * reset();
- *
- * var div = $("div").addClass("test").addClass("foo").addClass("bar");
- * div.removeClass("test").removeClass("bar").removeClass("foo");
- * var pass = true;
- * for ( var i = 0; i < div.size(); i++ ) {
- * if ( div.get(i).className.match(/test|bar|foo/) ) pass = false;
- * }
- * ok( pass, "Remove multiple classes" );
- *
* @name removeClass
* @type jQuery
* @param String class A CSS class to remove from the elements