Skip to content

Commit

Permalink
Firestore: equality_matcher.ts: fix missing custom assertion failure …
Browse files Browse the repository at this point in the history
…message in deep equals (#7519)

* equality_matcher.ts: fix absence of custom message in assertion failure messages

* equality_matcher.ts: remove usage of the now-deleted `msg` argument

* equality_matcher.ts: fix type of `originalFunction`
  • Loading branch information
dconeybe authored Aug 3, 2023
1 parent e037eee commit e201e53
Showing 1 changed file with 4 additions and 9 deletions.
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

0 comments on commit e201e53

Please sign in to comment.