Skip to content

Commit

Permalink
fix(platform-browser): remove obsolete shim for Map comparison in Jas…
Browse files Browse the repository at this point in the history
…mine (#45521)

Angular now uses Jasmine 2.8 as a minimum version (required by
protractor; most of it is using ^3.5.0 which currently resolves to
3.99.0), which makes this shim obsolete - all versions of Jasmine used
have Map comparison built in.

This shim causes problems for custom equality checkers - when using a
Map containing types needing a custom equality check, this  fails
because the call to `jasmine.matchersUtil.equals` from the shim does not
use any of the custom equality matchers.

PR Close #45521
  • Loading branch information
Samuel Littley authored and thePunderWoman committed Apr 12, 2022
1 parent b5f39c5 commit c7bf75d
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions packages/platform-browser/testing/src/matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,26 +131,6 @@ export const expect: <T = any>(actual: T) => NgMatchers<T> = _global.expect;
};

_global.beforeEach(function() {
// Custom handler for Map as we use Jasmine 2.4, and support for maps is not
// added until Jasmine 2.6.
// TODO(crisbeto): This entire equality tester should be removed.
// Keeping it in for now until the cleanup in cl/440328102 has landed.
if ((jasmine as any).matchersUtil) {
jasmine.addCustomEqualityTester(function compareMap(actual: any, expected: any): boolean {
if (actual instanceof Map) {
let pass = actual.size === expected.size;
if (pass) {
actual.forEach((v: any, k: any) => {
pass = pass && (jasmine as any).matchersUtil.equals(v, expected.get(k));
});
}
return pass;
} else {
// TODO(misko): we should change the return, but jasmine.d.ts is not null safe
return undefined!;
}
});
}
jasmine.addMatchers({
toBePromise: function() {
return {
Expand Down

0 comments on commit c7bf75d

Please sign in to comment.