Cleaned up specs for symbol property filtering

* Removed redundant spec
* Test the behavior of jasmineUnderTest, not the host jasmine
This commit is contained in:
Steve Gravrock
2022-05-09 17:11:36 -07:00
parent 841b212c66
commit 81f6eb45ea

View File

@@ -51,7 +51,7 @@ describe('toEqual', function() {
expect(compareEquals(actual, expected).message).toEqual(message);
});
it('reports differences between symbol properties', function() {
it('reports differences between enumerable symbol properties', function() {
const x = Symbol('x'),
actual = { [x]: 1, y: 3 },
expected = { [x]: 2, y: 3 },
@@ -60,6 +60,18 @@ describe('toEqual', function() {
expect(compareEquals(actual, expected).message).toEqual(message);
});
it('excludes non-enumerable symbol properties from the comparison', function() {
const sym = Symbol('foo');
const actual = {};
Object.defineProperty(actual, sym, {
value: '',
enumerable: false
});
const expected = {};
expect(compareEquals(actual, expected).pass).toBeTrue();
});
it('reports the difference between nested objects that are not equal', function() {
const actual = { x: { y: 1 } },
expected = { x: { y: 2 } },
@@ -1067,29 +1079,6 @@ describe('toEqual', function() {
// == Symbols ==
describe('Symbols', function() {
it('Enumerable symbols are compared', function() {
const sym = Symbol('foo');
const actual = {};
Object.defineProperty(actual, sym, {
value: '',
enumerable: true
});
const expected = { [sym]: '' };
expect(actual).toEqual(expected);
});
it('Symbols that cannot be enumerated are not compared ', function() {
const sym = Symbol('foo');
const actual = {};
Object.defineProperty(actual, sym, {
value: '',
enumerable: false
});
const expected = {};
expect(actual).toEqual(expected);
});
it('Fails if Symbol compared to Object', function() {
const sym = Symbol('foo');
const obj = {};