-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix diffing object contain readonly symbol key object (#10414)
- Loading branch information
Showing
12 changed files
with
241 additions
and
19 deletions.
There are no files selected for viewing
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
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,51 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`should work without error 1`] = ` | ||
"FAIL __tests__/dom.test.js | ||
✕ use toBe compare two div (<<REPLACED>>) | ||
✕ compare span and div (<<REPLACED>>) | ||
● use toBe compare two div | ||
expect(received).toBe(expected) // Object.is equality | ||
If it should pass with deep equality, replace \\"toBe\\" with \\"toStrictEqual\\" | ||
Expected: <div /> | ||
Received: serializes to the same string | ||
12 | const div1 = document.createElement('div'); | ||
13 | const div2 = document.createElement('div'); | ||
> 14 | expect(div1).toBe(div2); | ||
| ^ | ||
15 | }); | ||
16 | | ||
17 | test('compare span and div', () => { | ||
at Object.toBe (__tests__/dom.test.js:14:16) | ||
● compare span and div | ||
expect(received).toBe(expected) // Object.is equality | ||
- Expected - 1 | ||
+ Received + 1 | ||
- <span /> | ||
+ <div /> | ||
16 | | ||
17 | test('compare span and div', () => { | ||
> 18 | expect(document.createElement('div')).toBe(document.createElement('span')); | ||
| ^ | ||
19 | }); | ||
20 | | ||
at Object.toBe (__tests__/dom.test.js:18:41) | ||
Test Suites: 1 failed, 1 total | ||
Tests: 2 failed, 2 total | ||
Snapshots: 0 total | ||
Time: <<REPLACED>> | ||
Ran all test suites." | ||
`; |
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,16 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
|
||
import runJest from '../runJest'; | ||
import {replaceTime} from '../Utils'; | ||
|
||
test('should work without error', () => { | ||
const output = runJest('dom-diffing'); | ||
expect(output.failed).toBe(true); | ||
expect(replaceTime(output.stderr)).toMatchSnapshot(); | ||
}); |
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,19 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
|
||
/* eslint-env browser */ | ||
|
||
test('use toBe compare two div', () => { | ||
const div1 = document.createElement('div'); | ||
const div2 = document.createElement('div'); | ||
expect(div1).toBe(div2); | ||
}); | ||
|
||
test('compare span and div', () => { | ||
expect(document.createElement('div')).toBe(document.createElement('span')); | ||
}); |
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,3 @@ | ||
{ | ||
"jest": {} | ||
} |
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
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
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
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
29 changes: 29 additions & 0 deletions
29
packages/jest-matcher-utils/src/__tests__/deepCyclicCopyReplaceableDom.test.ts
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,29 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @jest-environment jsdom | ||
*/ | ||
/* eslint-env browser*/ | ||
import deepCyclicCopyReplaceable from '../deepCyclicCopyReplaceable'; | ||
|
||
test('should copy dom element', () => { | ||
const div = document.createElement('div'); | ||
const copied = deepCyclicCopyReplaceable(div); | ||
expect(copied).toEqual(div); | ||
expect(div === copied).toBe(false); //assert reference is not the same | ||
}); | ||
|
||
test('should copy complex element', () => { | ||
const div = document.createElement('div'); | ||
const span = document.createElement('span'); | ||
div.setAttribute('id', 'div'); | ||
div.innerText = 'this is div'; | ||
div.appendChild(span); | ||
const copied = deepCyclicCopyReplaceable(div); | ||
expect(copied).toEqual(div); | ||
expect(div === copied).toBe(false); //assert reference is not the same | ||
expect(div.children[0] === copied.children[0]).toBe(false); //assert reference is not the same | ||
}); |
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
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