Folded util.objectDifference into MatchersUtil

This was always an implementation detail of objectKeysAreDifferentFormatter,
and didn't really do what its name suggested.

* #1966
This commit is contained in:
Steve Gravrock
2022-05-07 14:03:26 -07:00
parent 468e9577cd
commit 9a27407d35
4 changed files with 20 additions and 76 deletions

View File

@@ -558,9 +558,17 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
return typeof obj === 'function';
}
// Returns an array of [k, v] pairs for eacch property that's in objA
// and not in objB.
function extraKeysAndValues(objA, objB) {
return MatchersUtil.keys(objA)
.filter(key => !j$.util.has(objB, key))
.map(key => [key, objA[key]]);
}
function objectKeysAreDifferentFormatter(pp, actual, expected, path) {
var missingProperties = j$.util.objectDifference(expected, actual),
extraProperties = j$.util.objectDifference(actual, expected),
var missingProperties = extraKeysAndValues(expected, actual),
extraProperties = extraKeysAndValues(actual, expected),
missingPropertiesMessage = formatKeyValuePairs(pp, missingProperties),
extraPropertiesMessage = formatKeyValuePairs(pp, extraProperties),
messages = [];

View File

@@ -75,12 +75,6 @@ getJasmineRequireObj().util = function(j$) {
return descriptor;
};
util.objectDifference = function(obj, toRemove) {
return j$.MatchersUtil.keys(obj)
.filter(key => !util.has(toRemove, key))
.map(key => [key, obj[key]]);
};
util.has = function(obj, key) {
return Object.prototype.hasOwnProperty.call(obj, key);
};