* @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' );
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);
vardata=$(':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');
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:";
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";
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 (//*)");