X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fajax.js;h=fb328bcc75b31b14d5144d1f15175dc85cff77a5;hb=9d8d74569c8114f9c9b0f42bca71536e154c5944;hp=a54f7c912d7a795895ca0a0ef056f1bb9659eae9;hpb=a64ad8b4e97e68b51996268ecc7bcdf4271d082c;p=jquery.git diff --git a/test/unit/ajax.js b/test/unit/ajax.js index a54f7c9..fb328bc 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -213,18 +213,31 @@ test("serialize()", function() { }); test("jQuery.param()", function() { - expect(4); + expect(8); var params = {foo:"bar", baz:42, quux:"All your base are belong to us"}; equals( jQuery.param(params), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" ); params = {someName: [1, 2, 3], regularThing: "blah" }; equals( jQuery.param(params), "someName=1&someName=2&someName=3®ularThing=blah", "with array" ); + params = {foo: ['a', 'b', 'c']}; + equals( jQuery.param(params), "foo=a&foo=b&foo=c", "with array of strings" ); + params = {"foo[]":["baz", 42, "All your base are belong to us"]}; equals( jQuery.param(params), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" ); params = {"foo[bar]":"baz", "foo[beep]":42, "foo[quux]":"All your base are belong to us"}; equals( jQuery.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" ); + + params = {foo: {bar: "baz", beep: 42, quux: "All your base are belong to us"}}; + equals( jQuery.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "nested object" ); + + params = {foo: {"bar[]": [1,2,3]}}; + equals( jQuery.param(params), "foo%5Bbar%5D%5B%5D=1&foo%5Bbar%5D%5B%5D=2&foo%5Bbar%5D%5B%5D=3", "nested array"); + + params = {foo: [{bar: "baz", beep: 42}, {bar: "baz2", beep: 43}]}; + equals( jQuery.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bbar%5D=baz2&foo%5Bbeep%5D=43", "nested array of objects" ); + }); test("synchronous request", function() {