forked from jestjs/jest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compare objects with Symbol keys (jestjs#3437)
* compare objects with Symbol keys * Update symbol-in-objects-test.js
- Loading branch information
1 parent
e4ad481
commit bade6b0
Showing
2 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
packages/jest-matchers/src/__tests__/symbol-in-objects-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @emails oncall+jsinfra | ||
*/ | ||
|
||
'use strict'; | ||
|
||
describe('Symbol in objects', () => { | ||
test('should compare objects with Symbol keys', () => { | ||
const sym = Symbol('foo'); | ||
const obj1 = {[sym]: 'one'}; | ||
const obj2 = {[sym]: 'two'}; | ||
const obj3 = {[sym]: 'one'}; | ||
|
||
expect(obj1).toEqual(obj3); | ||
expect(obj1).not.toEqual(obj2); | ||
}); | ||
|
||
test('should compare objects with mixed keys and Symbol', () => { | ||
const sym = Symbol('foo2'); | ||
const obj1 = {foo: 2, [sym]: 'one'}; | ||
const obj2 = {foo: 2, [sym]: 'two'}; | ||
const obj3 = {foo: 2, [sym]: 'one'}; | ||
|
||
expect(obj1).toEqual(obj3); | ||
expect(obj1).not.toEqual(obj2); | ||
}); | ||
|
||
test('should compare objects with different Symbol keys', () => { | ||
const sym = Symbol('foo'); | ||
const sym2 = Symbol('foo'); | ||
const obj1 = {[sym]: 'one'}; | ||
const obj2 = {[sym2]: 'one'}; | ||
const obj3 = {[sym]: 'one'}; | ||
|
||
expect(obj1).toEqual(obj3); | ||
expect(obj1).not.toEqual(obj2); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters