Change message for extra elements at end of actual array. #1485

This commit is contained in:
Majid Razvi
2018-03-10 00:05:07 -07:00
parent 85b2a8c6c4
commit 11b8b59e03
2 changed files with 71 additions and 7 deletions

View File

@@ -225,8 +225,14 @@ getJasmineRequireObj().matchersUtil = function(j$) {
});
for (i = 0; i < aLength || i < bLength; i++) {
var formatter = false;
diffBuilder.withPath(i, function() {
result = eq(i < aLength ? a[i] : void 0, i < bLength ? b[i] : void 0, aStack, bStack, customTesters, diffBuilder) && result;
if (i >= bLength) {
diffBuilder.record(a[i], void 0, actualArrayIsLongerFormatter);
result = false;
} else {
result = eq(i < aLength ? a[i] : void 0, i < bLength ? b[i] : void 0, aStack, bStack, customTesters, diffBuilder) && result;
}
});
}
if (!result) {
@@ -452,6 +458,13 @@ getJasmineRequireObj().matchersUtil = function(j$) {
', but was ' + j$.pp(actual) + '.';
}
function actualArrayIsLongerFormatter(actual, expected, path) {
return 'Unexpected ' +
path + (path.depth() ? ' = ' : '') +
j$.pp(actual) +
' in array.';
}
function formatKeyValuePairs(obj) {
var formatted = '';
for (var key in obj) {