简体   繁体   中英

qunit deepEqual test fails on identical objects

Why does the following test fail?

function queryString2Map(queryString) {
    var pairs = [], i, keyValuePair, key, value, map = {};
    if (queryString !== '') {
        pairs = queryString.split('&');
        for (i = 0; i < pairs.length; i += 1) {
            keyValuePair = pairs[i].split('=');
            key = decodeURIComponent(keyValuePair[0]);
            value = (keyValuePair.length > 1) ? decodeURIComponent(keyValuePair[1]) : undefined;
            map[key] = value;
        }
    }
    return map;
}


test("queryString2Map", 1, function () {
    var qs = 'a=123&bob=%20a%20&symbols=%22%24%25%5E%26%3C%3E%2F%5C%3A~%40%3B%23&undef';
    var map = {
        'a': '123',
        'bob': ' a ', 
        'symbols': '"$%^&<>/\\:~@;#',
        'undef': undefined
    };
    deepEqual(queryString2Map(qs), map, "querystring converted to map");
});

the object returned by queryString2Map is identical to the map object in the test so why does the test fail?

尝试使用propEquals时,未显示的父原型对象之间可能会有一些差异。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM