assert: fix the string length check for printing the simple diff

PR-URL: https://github.com/nodejs/node/pull/55474
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
Giovanni Bucci authored and GitHub committed 2024-11-02 15:12:12 +00:00
1 parent 81859cf01f
commit 10cce655ca
3 files changed
+31 -16

No files matched your search

+8 -1
View File
@@ -134,7 +134,14 @@ function getStackedDiff(actual, expected) {
}
function getSimpleDiff(originalActual, actual, originalExpected, expected) {
const stringsLen = actual.length + expected.length;
let stringsLen = actual.length + expected.length;
// Accounting for the quotes wrapping strings
if (typeof originalActual === 'string') {
stringsLen -= 2;
}
if (typeof originalExpected === 'string') {
stringsLen -= 2;
}
if (stringsLen <= kMaxShortStringLength && (originalActual !== 0 || originalExpected !== 0)) {
return { message: `${actual} !== ${expected}`, header: '' };
}