-
Notifications
You must be signed in to change notification settings - Fork 49.9k
Remove tests in ReactDOMComponent-test depending on internal API #11337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gaearon
merged 7 commits into
facebook:master
from
AudyOdi:remove-inputvaluetrackingdep-reactdomcomp
Nov 10, 2017
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ae96f21
Remove inputValueTracking from ReactDOMComponent-test dependency
AudyOdi cb7b802
prettier
AudyOdi 3e9bfe3
use node._valueTracker and add some test cases to make sure that valu…
AudyOdi d480ce7
using Object.getOwnPropertyDescriptor to get the tracked value
AudyOdi 4614636
move getValueTracker to each test case and use its corresponding prot…
AudyOdi aa75dde
remove tests and move the value tracker definition before React is im…
AudyOdi 2dadb8d
Delete these tests completely
gaearon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -14,7 +14,6 @@ describe('ReactDOMComponent', () => { | |
| var ReactTestUtils; | ||
| var ReactDOM; | ||
| var ReactDOMServer; | ||
| var inputValueTracking; | ||
|
|
||
| function normalizeCodeLocInfo(str) { | ||
| return str && str.replace(/\(at .+?:\d+\)/g, '(at **)'); | ||
|
|
@@ -26,8 +25,6 @@ describe('ReactDOMComponent', () => { | |
| ReactDOM = require('react-dom'); | ||
| ReactDOMServer = require('react-dom/server'); | ||
| ReactTestUtils = require('react-dom/test-utils'); | ||
| // TODO: can we express this test with only public API? | ||
| inputValueTracking = require('../client/inputValueTracking'); | ||
| }); | ||
|
|
||
| describe('updateDOM', () => { | ||
|
|
@@ -1152,18 +1149,46 @@ describe('ReactDOMComponent', () => { | |
| container, | ||
| ); | ||
|
|
||
| var tracker = inputValueTracking._getTrackerFromNode(inst); | ||
| var getValueTracker = Object.getOwnPropertyDescriptor( | ||
| HTMLInputElement.prototype, | ||
| 'value', | ||
| ).get; | ||
|
|
||
| expect(tracker.getValue()).toEqual('foo'); | ||
| expect(getValueTracker.call(inst)).toEqual('foo'); | ||
|
|
||
| inst.defaultValue = 'new foo'; | ||
| expect(getValueTracker.call(inst)).not.toEqual('new foo'); | ||
|
||
| expect(getValueTracker.call(inst)).toEqual('foo'); | ||
|
|
||
| inst.value = 'bar'; | ||
| expect(getValueTracker.call(inst)).toEqual('bar'); | ||
|
|
||
| // even if the value changes to empty string, should not return to defaultValue | ||
| inst.value = ''; | ||
| expect(getValueTracker.call(inst)).toEqual(''); | ||
| }); | ||
|
|
||
| it('should track textarea values', () => { | ||
| var container = document.createElement('div'); | ||
| var inst = ReactDOM.render(<textarea defaultValue="foo" />, container); | ||
|
|
||
| var tracker = inputValueTracking._getTrackerFromNode(inst); | ||
| var getValueTracker = Object.getOwnPropertyDescriptor( | ||
| HTMLTextAreaElement.prototype, | ||
| 'value', | ||
| ).get; | ||
|
|
||
| expect(getValueTracker.call(inst)).toEqual('foo'); | ||
|
|
||
| inst.defaultValue = 'new foo'; | ||
| expect(getValueTracker.call(inst)).not.toEqual('new foo'); | ||
| expect(getValueTracker.call(inst)).toEqual('foo'); | ||
|
|
||
| inst.value = 'bar'; | ||
| expect(getValueTracker.call(inst)).toEqual('bar'); | ||
|
|
||
| expect(tracker.getValue()).toEqual('foo'); | ||
| // even if the value changes to empty string, should not return to defaultValue | ||
| inst.value = ''; | ||
| expect(getValueTracker.call(inst)).toEqual(''); | ||
| }); | ||
|
|
||
| it('should throw for children on void elements', () => { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should ideally be done before React is imported.