I’m trying to test a utility method I have that creates urlencoded query strings. It somehow decodes “expected” in to: ?foo=foo val&bar=bar&val … so it’s decoding the urlencoding!
test("test make_params properly url encodes", function() {
var o = {"foo":'foo val',"bar":'bar&val'};
var actual = make_params(o);
equals('?foo=foo+val&bar=bar%26val', actual, "Expected urlencoded string built to be" + '?foo=foo+val&bar=bar%26val');
});
Results in:
1. Expected urlencoded string built to be?foo=foo+val&bar=bar%26val, expected:
“?foo=foo val&bar=bar&val” result: “?foo=foo+val&bar=bar%26val”, diff: “?foo=foo val&bar=bar&val” “?foo=foo+val&bar=bar%26val”
Is this a bug in qunit or am I overlooking something?
One minor issue: equals expect the actual value as the first argument, the expected as the second. And equals is now deprecated in favor of equal.
Based on that its likely that the test works fine, but the make_params method doesn’t actually encode anything.