From 6f7d42a45b6af8147308fa6544601bbfb30dd1ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Oddsson?= Date: Mon, 20 May 2024 09:16:33 +0000 Subject: [PATCH] add jsdoc --- lib/chai/core/assertions.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/chai/core/assertions.js b/lib/chai/core/assertions.js index c88a758d..7dfd4fb1 100644 --- a/lib/chai/core/assertions.js +++ b/lib/chai/core/assertions.js @@ -3933,7 +3933,14 @@ Assertion.addProperty('finite', function(msg) { ) }); -function compare(expected, actual) { +/** + * A subset-aware compare function + * + * @param {unknown} expected + * @param {unknown} actual + * @returns {void} + */ +function compareSubset(expected, actual) { if (expected === actual) { return true; } @@ -3954,7 +3961,7 @@ function compare(expected, actual) { var aa = Array.prototype.slice.call(actual); return expected.every(function (exp) { return aa.some(function (act) { - return compare(exp, act); + return compareSubset(exp, act); }); }); } @@ -3971,7 +3978,7 @@ function compare(expected, actual) { var eo = expected[key]; var ao = actual[key]; if (typeof eo === 'object' && eo !== null && ao !== null) { - return compare(eo, ao); + return compareSubset(eo, ao); } if (typeof eo === 'function') { return eo(ao); @@ -3985,7 +3992,7 @@ Assertion.addMethod('containSubset', function (expected) { const showDiff = config.showDiff; this.assert( - compare(expected, actual), + compareSubset(expected, actual), 'expected #{act} to contain subset #{exp}', 'expected #{act} to not contain subset #{exp}', expected,