aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAriel Flesler <aflesler@gmail.com>2008-05-27 22:46:28 +0000
committerAriel Flesler <aflesler@gmail.com>2008-05-27 22:46:28 +0000
commitc6e88b16e9f6e45d87019db45dd04d27482d25d7 (patch)
tree116d2a7b56b7fc523dca4ad708c2f851f342846b /test
parent7ec772374d132149d72418abce4569dedbd4168b (diff)
downloadjquery-c6e88b16e9f6e45d87019db45dd04d27482d25d7.tar.gz
jquery-c6e88b16e9f6e45d87019db45dd04d27482d25d7.zip
test runner: a test for load() with a hash of data, and another for load() with a string of data (#1516).
It includes a php that dumps all the GET and POST vars to html elements, where the key makes the id, and the value the text.
Diffstat (limited to 'test')
-rw-r--r--test/data/params_html.php12
-rw-r--r--test/unit/ajax.js24
2 files changed, 36 insertions, 0 deletions
diff --git a/test/data/params_html.php b/test/data/params_html.php
new file mode 100644
index 000000000..e170e8a93
--- /dev/null
+++ b/test/data/params_html.php
@@ -0,0 +1,12 @@
+<div id="post">
+<?php
+ foreach( $_POST as $key=>$value )
+ echo "<b id='$key'>$value</b>";
+?>
+</div>
+<div id="get">
+<?php
+ foreach( $_GET as $key=>$value )
+ echo "<b id='$key'>$value</b>";
+?>
+</div> \ No newline at end of file
diff --git a/test/unit/ajax.js b/test/unit/ajax.js
index fc2ab9e33..9514a8edc 100644
--- a/test/unit/ajax.js
+++ b/test/unit/ajax.js
@@ -385,6 +385,30 @@ test("load(String, Function) - check file with only a script tag", function() {
});
});
+test("load(String, Object, Function)", function() {
+ expect(2);
+ stop();
+
+ $('<div />').load(url('data/params_html.php'), { foo:3, bar:'ok' }, function() {
+ var $post = $(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();
+ });
+});
+
+test("load(String, String, Function)", function() {
+ expect(2);
+ stop();
+
+ $('<div />').load(url('data/params_html.php'), 'foo=3&bar=ok', function() {
+ var $get = $(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() {
expect(2);
stop();