-
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
Changes from 4 commits
ae96f21
cb7b802
3e9bfe3
d480ce7
4614636
aa75dde
2dadb8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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', () => { | ||
|
|
@@ -832,6 +829,12 @@ describe('ReactDOMComponent', () => { | |
|
|
||
| describe('mountComponent', () => { | ||
| var mountComponent; | ||
| var getValueTracker = (node: HTMLInputElement | HTMLTextAreaElement) => { | ||
| return Object.getOwnPropertyDescriptor( | ||
| node.constructor.prototype, | ||
| 'value', | ||
| ).get; | ||
| }; | ||
|
|
||
| beforeEach(() => { | ||
| mountComponent = function(props) { | ||
|
|
@@ -1151,19 +1154,37 @@ describe('ReactDOMComponent', () => { | |
| <input type="text" defaultValue="foo" />, | ||
| container, | ||
| ); | ||
| var getTrackedValue = getValueTracker(inst); | ||
|
||
| expect(getTrackedValue.call(inst)).toEqual('foo'); | ||
|
|
||
| var tracker = inputValueTracking._getTrackerFromNode(inst); | ||
| inst.defaultValue = 'new foo'; | ||
| expect(getTrackedValue.call(inst)).not.toEqual('new foo'); | ||
| expect(getTrackedValue.call(inst)).toEqual('foo'); | ||
|
|
||
| expect(tracker.getValue()).toEqual('foo'); | ||
| inst.value = 'bar'; | ||
| expect(getTrackedValue.call(inst)).toEqual('bar'); | ||
|
|
||
| // even if the value changes to empty string, should not return to defaultValue | ||
| inst.value = ''; | ||
| expect(getTrackedValue.call(inst)).toEqual(''); | ||
| }); | ||
|
|
||
| it('should track textarea values', () => { | ||
| var container = document.createElement('div'); | ||
| var inst = ReactDOM.render(<textarea defaultValue="foo" />, container); | ||
| var getTrackedValue = getValueTracker(inst); | ||
| expect(getTrackedValue.call(inst)).toEqual('foo'); | ||
|
|
||
| inst.defaultValue = 'new foo'; | ||
| expect(getTrackedValue.call(inst)).not.toEqual('new foo'); | ||
| expect(getTrackedValue.call(inst)).toEqual('foo'); | ||
|
|
||
| var tracker = inputValueTracking._getTrackerFromNode(inst); | ||
| inst.value = 'bar'; | ||
| expect(getTrackedValue.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(getTrackedValue.call(inst)).toEqual(''); | ||
| }); | ||
|
|
||
| it('should throw for children on void elements', () => { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
Nice!
Really liked what you did here for the html interfaces. 👍