Include symbol properties in matcher diffs

* #1966
This commit is contained in:
Steve Gravrock
2022-05-07 13:26:15 -07:00
parent 9d80377fe3
commit 468e9577cd
7 changed files with 81 additions and 36 deletions

View File

@@ -196,10 +196,34 @@ describe('util', function() {
quux: 7
};
expect(jasmineUnderTest.util.objectDifference(a, b)).toEqual({
foo: 3,
baz: 5
});
expect(jasmineUnderTest.util.objectDifference(a, b)).toEqual([
['foo', 3],
['baz', 5]
]);
});
it('includes Symbol keys', function() {
const missing = Symbol('missing');
const both = Symbol('both');
const symbolDuplicated1 = Symbol('symbolDuplicated');
const symbolDuplicated2 = Symbol('symbolDuplicated');
const added = Symbol('added');
const a = {
[missing]: 1,
[both]: 2,
[symbolDuplicated1]: 3
};
const b = {
[both]: 'anything',
[symbolDuplicated2]: 4,
[added]: 5
};
expect(jasmineUnderTest.util.objectDifference(a, b)).toEqual([
[missing, 1],
[symbolDuplicated1, 3]
]);
});
it('only looks at own properties of both objects', function() {
@@ -214,8 +238,8 @@ describe('util', function() {
const b = new Foo();
b.y = 2;
expect(jasmineUnderTest.util.objectDifference(a, b)).toEqual({ x: 1 });
expect(jasmineUnderTest.util.objectDifference(b, a)).toEqual({ y: 2 });
expect(jasmineUnderTest.util.objectDifference(a, b)).toEqual([['x', 1]]);
expect(jasmineUnderTest.util.objectDifference(b, a)).toEqual([['y', 2]]);
});
});