Skip to content

Firestore: equality_matcher.ts: fix missing custom assertion failure message in deep equals #7519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 3, 2023
Merged
Changes from all commits
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
13 changes: 4 additions & 9 deletions packages/firestore/test/util/equality_matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function customDeepEqual(
}

/** The original equality function passed in by chai(). */
let originalFunction: ((r: unknown, l: unknown) => boolean) | null = null;
let originalFunction: ((expected: unknown) => void) | null = null;

export function addEqualityMatcher(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -136,15 +136,10 @@ export function addEqualityMatcher(
const Assertion = chai.Assertion;

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
const assertEql = (_super: (r: unknown, l: unknown) => boolean) => {
const assertEql = (_super: (expected: unknown) => void) => {
originalFunction = originalFunction || _super;
return function (
this: Chai.Assertion,
expected?: unknown,
msg?: unknown
): void {
return function (this: Chai.Assertion, expected?: unknown): void {
if (isActive) {
utils.flag(this, 'message', msg);
const actual = utils.flag(this, 'object');

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -161,7 +156,7 @@ export function addEqualityMatcher(
/*showDiff=*/ true
);
} else if (originalFunction) {
originalFunction.call(this, expected, msg);
originalFunction.call(this, expected);
}
};
};
Expand Down