toEqual does not compare symbols that cannot be enumerated

This commit is contained in:
suke
2022-04-26 23:31:44 +09:00
parent 694375e4ea
commit dfa94c70c1
3 changed files with 41 additions and 4 deletions

View File

@@ -1042,6 +1042,29 @@ 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 = {};