Make toEqual matcher report the difference between objects
- Mismatches deep within object/array structures are pinpointed with a JsonPath-like syntax.
This commit is contained in:
committed by
Ben Christel
parent
5a76e59d5b
commit
d5e6bf47ed
@@ -67,5 +67,21 @@ getJasmineRequireObj().util = function() {
|
||||
return descriptor;
|
||||
};
|
||||
|
||||
util.objectDifference = function(obj, toRemove) {
|
||||
var diff = {};
|
||||
|
||||
for (var key in obj) {
|
||||
if (util.has(obj, key) && !util.has(toRemove, key)) {
|
||||
diff[key] = obj[key];
|
||||
}
|
||||
}
|
||||
|
||||
return diff;
|
||||
};
|
||||
|
||||
util.has = function(obj, key) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, key);
|
||||
};
|
||||
|
||||
return util;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user