ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass // [ wonkyQS, canonicalQS, obj ]
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass ["foo=bar&foo=quux", "foo%5B%5D=bar&foo%5B%5D=quux", {"foo" : ["bar", "quux"]}],
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass ["foo=1&bar=2", "foo=1&bar=2", {"foo" : 1, "bar" : 2}],
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass ["my+weird+field=q1%212%22%27w%245%267%2Fz8%29%3F", "my%20weird%20field=q1!2%22'w%245%267%2Fz8)%3F", {"my weird field" : "q1!2\"'w$5&7/z8)?" }],
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass ["foo%3Dbaz=bar", "foo%3Dbaz=bar", {"foo=baz" : "bar"}],
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass ["foo=baz=bar", "foo=baz%3Dbar", {"foo" : "baz=bar"}],
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass ["str=foo&arr[]=1&arr[]=2&arr[]=3&obj[a]=bar&obj[b][]=4&obj[b][]=5&obj[b][]=6&obj[b][]=&obj[c][]=4&obj[c][]=5&obj[c][][somestr]=baz&obj[objobj][objobjstr]=blerg&somenull=&undef=", "str=foo&arr%5B%5D=1&arr%5B%5D=2&arr%5B%5D=3&obj%5Ba%5D=bar&obj%5Bb%5D%5B%5D=4&obj%5Bb%5D%5B%5D=5&obj%5Bb%5D%5B%5D=6&obj%5Bb%5D%5B%5D=&obj%5Bc%5D%5B%5D=4&obj%5Bc%5D%5B%5D=5&obj%5Bc%5D%5B%5D%5Bsomestr%5D=baz&obj%5Bobjobj%5D%5Bobjobjstr%5D=blerg&somenull=&undef=", {
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass ["foo[bar][bla]=baz&foo[bar][bla]=blo", "foo%5Bbar%5D%5Bbla%5D%5B%5D=baz&foo%5Bbar%5D%5Bbla%5D%5B%5D=blo", {"foo":{"bar":{"bla":["baz","blo"]}}}],
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass ["foo[bar][][bla]=baz&foo[bar][][bla]=blo", "foo%5Bbar%5D%5B%5D%5Bbla%5D=baz&foo%5Bbar%5D%5B%5D%5Bbla%5D=blo", {"foo":{"bar":[{"bla":"baz"},{"bla":"blo"}]}}],
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass ["foo[bar][bla][]=baz&foo[bar][bla][]=blo", "foo%5Bbar%5D%5Bbla%5D%5B%5D=baz&foo%5Bbar%5D%5Bbla%5D%5B%5D=blo", {"foo":{"bar":{"bla":["baz","blo"]}}}],
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass // [ wonkyQS, canonicalQS, obj ]
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass ["foo:bar;foo:quux", "foo%5B%5D:bar;foo%5B%5D:quux", {"foo" : ["bar", "quux"]}],
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass ["foo:1&bar:2;baz:quux", "foo:1%26bar%3A2;baz:quux", {"foo":"1&bar:2", "baz":"quux"}],
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass ["foo%3Abaz:bar", "foo%3Abaz:bar", {"foo:baz":"bar"}],
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass ["foo:baz:bar", "foo:baz%3Abar", {"foo":"baz:bar"}]
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass // [ wonkyObj, qs, canonicalObj ]
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass var extendedFunction = function () {};
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass [ {regexp: new RegExp(".", "g")}, "regexp=", {"regexp":""} ],
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass [ {f:new Boolean(false), t:new Boolean(true)}, "f=0&t=1", {"f":0, "t":1} ],
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass // Tests Below...
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass var suite = new Y.Test.Suite("Query String Tests");
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass testParseBasic : function() {
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass Y.Array.forEach(qsTestCases, function (testCase) {
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass Y.Assert.areSame(J(testCase[2]), J(Y.QueryString.parse(testCase[0])));
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass testParseColon : function () {
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass Y.Array.forEach(qsColonTestCases, function (testCase) {
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass Y.Assert.areSame(J(testCase[2]), J(Y.QueryString.parse(testCase[0], ";", ":")));
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass testParseWeird : function () {
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass Y.Array.forEach(qsWeirdObjects, function (testCase) {
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass Y.Assert.areSame(J(testCase[2]), J(Y.QueryString.parse(testCase[1])));
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass testNested : function () {
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass var f = Y.QueryString.parse("a=b&q=x%3Dy%26y%3Dz");
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass Y.Assert.areSame(J(f), J({ a : "b", q : { x : "y", y : "z" } }));
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass testNestedColon : function () {
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass var f = Y.QueryString.parse("a:b;q:x%3Ay%3By%3Az", ";", ":");
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass Y.Assert.areSame(J(f), J({ a : "b", q : { x : "y", y : "z" } }));
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass testStringifyCyclical : "QueryString.stringify. Cyclical reference"
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass testStringifyBasic : function () {
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass Y.Array.forEach(qsTestCases, function (testCase) {
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass Y.Assert.areSame(testCase[1], Y.QueryString.stringify(testCase[2], { arrayKey: true }));
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass testStringifyColon : function () {
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass Y.Array.forEach(qsColonTestCases, function (testCase) {
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass Y.Assert.areSame(testCase[1], Y.QueryString.stringify(testCase[2], { arrayKey: true, sep: ";", eq: ":" }));
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass testStringifyWeird : function () {
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass Y.Array.forEach(qsWeirdObjects, function (testCase) {
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass Y.Assert.areSame(testCase[1], Y.QueryString.stringify(testCase[0]), { arrayKey: true });
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass testNested : function () {
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass }, { arrayKey: true })
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass testNestedColon : function () {
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass testArrayKey : function () {
ae3b364068d9a32a9c7a81fd9530d90496943d45Dav Glass var f = Y.QueryString.stringify({ foo: ["bar","baz"] });