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:
@@ -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 = [];
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user