Skip to content

Commit

Permalink
Relax test about rendering top-level null (#8640)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Dec 27, 2016
1 parent 119294d commit 38ed61f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
1 change: 0 additions & 1 deletion scripts/fiber/tests-failing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ src/renderers/shared/shared/__tests__/ReactCompositeComponent-test.js

src/renderers/shared/shared/__tests__/ReactEmptyComponent-test.js
* should still throw when rendering to undefined
* throws when rendering null at the top level

src/renderers/shared/shared/__tests__/ReactMultiChildText-test.js
* should reorder keyed text nodes
Expand Down
1 change: 1 addition & 0 deletions scripts/fiber/tests-passing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,7 @@ src/renderers/shared/shared/__tests__/ReactEmptyComponent-test.js
* should distinguish between a script placeholder and an actual script tag
* should have findDOMNode return null when multiple layers of composite components render to the same null placeholder
* works when switching components
* can render null at the top level
* does not break when updating during mount
* preserves the dom node during updates

Expand Down
18 changes: 12 additions & 6 deletions src/renderers/shared/shared/__tests__/ReactEmptyComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,20 @@ describe('ReactEmptyComponent', () => {
expect(assertions).toBe(3);
});

it('throws when rendering null at the top level', () => {
// TODO: This should actually work since `null` is a valid ReactNode
it('can render null at the top level', () => {
var div = document.createElement('div');
expect(function() {

if (ReactDOMFeatureFlags.useFiber) {
ReactDOM.render(null, div);
}).toThrowError(
'ReactDOM.render(): Invalid component element.'
);
expect(div.innerHTML).toBe('');
} else {
// Stack does not implement this.
expect(function() {
ReactDOM.render(null, div);
}).toThrowError(
'ReactDOM.render(): Invalid component element.'
);
}
});

it('does not break when updating during mount', () => {
Expand Down

0 comments on commit 38ed61f

Please sign in to comment.