Skip to content

Commit

Permalink
Don't test input value clean-up in Fiber
Browse files Browse the repository at this point in the history
Fiber doesn't clean up host components; relies on GC.
  • Loading branch information
acdlite committed Feb 8, 2017
1 parent b187142 commit f4cabaf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
2 changes: 0 additions & 2 deletions scripts/fiber/tests-failing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ src/renderers/__tests__/refs-test.js
* Should increase refs with an increase in divs

src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
* should clean up input value tracking
* should clean up input textarea tracking
* gives source code refs for unknown prop warning (ssr)
* gives source code refs for unknown prop warning for exact elements (ssr)
* gives source code refs for unknown prop warning for exact elements in composition (ssr)
Expand Down
37 changes: 20 additions & 17 deletions src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ describe('ReactDOMComponent', () => {
var React;
var ReactTestUtils;
var ReactDOM;
var ReactDOMFeatureFlags;
var ReactDOMServer;
var inputValueTracking;
var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');

function normalizeCodeLocInfo(str) {
return str && str.replace(/\(at .+?:\d+\)/g, '(at **)');
Expand Down Expand Up @@ -1206,29 +1206,32 @@ describe('ReactDOMComponent', () => {
});

describe('unmountComponent', () => {
it('should clean up input value tracking', () => {
var container = document.createElement('div');
var node = ReactDOM.render(<input type="text" defaultValue="foo"/>, container);
var tracker = inputValueTracking._getTrackerFromNode(node);
// Fiber does not have a clean-up phase for host components; relies on GC
if (!ReactDOMFeatureFlags.useFiber) {
it('should clean up input value tracking', () => {
var container = document.createElement('div');
var node = ReactDOM.render(<input type="text" defaultValue="foo"/>, container);
var tracker = inputValueTracking._getTrackerFromNode(node);

spyOn(tracker, 'stopTracking');
spyOn(tracker, 'stopTracking');

ReactDOM.unmountComponentAtNode(container);
ReactDOM.unmountComponentAtNode(container);

expect(tracker.stopTracking.calls.count()).toBe(1);
});
expect(tracker.stopTracking.calls.count()).toBe(1);
});

it('should clean up input textarea tracking', () => {
var container = document.createElement('div');
var node = ReactDOM.render(<textarea defaultValue="foo"/>, container);
var tracker = inputValueTracking._getTrackerFromNode(node);
it('should clean up input textarea tracking', () => {
var container = document.createElement('div');
var node = ReactDOM.render(<textarea defaultValue="foo"/>, container);
var tracker = inputValueTracking._getTrackerFromNode(node);

spyOn(tracker, 'stopTracking');
spyOn(tracker, 'stopTracking');

ReactDOM.unmountComponentAtNode(container);
ReactDOM.unmountComponentAtNode(container);

expect(tracker.stopTracking.calls.count()).toBe(1);
});
expect(tracker.stopTracking.calls.count()).toBe(1);
});
}

it('unmounts children before unsetting DOM node info', () => {
class Inner extends React.Component {
Expand Down

0 comments on commit f4cabaf

Please sign in to comment.