fix(core): use addCustomEqualityTester instead of overriding toEqual (#22983)
This propagates other custom equality testers added by users. Additionally, if an Angular project is using jasmine 2.6+, it will allow Jasmine's custom object differ to print out pretty test error messages. fixes #22939 PR Close #22983
This commit is contained in:

committed by
Miško Hevery

parent
c94a2c9e3f
commit
0922228024
@ -21,6 +21,18 @@ class SpyTestObj extends SpyObject {
|
||||
|
||||
{
|
||||
describe('testing', () => {
|
||||
describe('should respect custom equality tester', () => {
|
||||
beforeEach(() => {
|
||||
const equalIfMarried =
|
||||
(first: any, second: any) => { return first === 'kevin' && second === 'patricia'; };
|
||||
jasmine.addCustomEqualityTester(equalIfMarried);
|
||||
});
|
||||
|
||||
it('for positive test', () => { expect('kevin').toEqual('patricia'); });
|
||||
|
||||
it('for negative test', () => { expect('kevin').not.toEqual('kevin'); });
|
||||
});
|
||||
|
||||
describe('equality', () => {
|
||||
it('should structurally compare objects', () => {
|
||||
const expected = new TestObj(new TestObj({'one': [1, 2]}));
|
||||
|
Reference in New Issue
Block a user