Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Variable Naming and Function Doc
  • Loading branch information
BreadInvasion committed Jan 22, 2025
commit 9f48750866e30d23ddc8b02960cba8459634f189
20 changes: 12 additions & 8 deletions lib/chai/core/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4068,7 +4068,7 @@ Assertion.addProperty('finite', function (_msg) {
*
* @param {unknown} expected
* @param {unknown} actual
* @returns {void}
* @returns {boolean}
*/
function compareSubset(expected, actual) {
if (expected === actual) {
Expand Down Expand Up @@ -4104,15 +4104,19 @@ function compareSubset(expected, actual) {
}

return Object.keys(expected).every(function (key) {
var eo = expected[key];
var ao = actual[key];
if (typeof eo === 'object' && eo !== null && ao !== null) {
return compareSubset(eo, ao);
var expectedValue = expected[key];
var actualValue = actual[key];
if (
typeof expectedValue === 'object' &&
expectedValue !== null &&
actualValue !== null
) {
return compareSubset(expectedValue, actualValue);
}
if (typeof eo === 'function') {
return eo(ao);
if (typeof expectedValue === 'function') {
return expectedValue(actualValue);
}
return ao === eo;
return actualValue === expectedValue;
});
}

Expand Down
Loading