QUnit 和 urlencode
我正在尝试测试一个创建 urlencoded 查询字符串的实用方法。它以某种方式将“预期”解码为: ?foo=foo val&bar=bar&val ...所以它正在解码 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');
});
结果: 1. 预期的urlencoded字符串构建为?foo=foo+val&bar=bar%26val,预期: "?foo=foo val&bar=bar&val" 结果: "?foo=foo+val&bar=bar%26val", diff: "?foo=foo val&bar=bar& val" "?foo=foo+val&bar=bar%26val"
这是 qunit 中的错误还是我忽略了某些东西?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个小问题:等于期望实际值作为第一个参数,期望值作为第二个参数。现在 equals 已被弃用,支持 equal。
基于此,测试很可能工作正常,但 make_params 方法实际上并不编码任何内容。
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.