Relax test about rendering top-level null (#8640)
Dan Abramov committed
Dec 27, 2016 at 08:38 UTC
38ed61f4c4333ee5ac99532478e832d7b878d655
3 files changed
+13
-7
scripts/fiber/tests-failing.txt
-1
@@ -74,7 +74,6 @@ src/renderers/shared/shared/__tests__/ReactCompositeComponent-test.js
74
75
src/renderers/shared/shared/__tests__/ReactEmptyComponent-test.js
76
* should still throw when rendering to undefined
77
-* throws when rendering null at the top level
77
78
src/renderers/shared/shared/__tests__/ReactMultiChildText-test.js
79
* should reorder keyed text nodes
scripts/fiber/tests-passing.txt
+1
@@ -1403,6 +1403,7 @@ src/renderers/shared/shared/__tests__/ReactEmptyComponent-test.js
1403
* should distinguish between a script placeholder and an actual script tag
1404
* should have findDOMNode return null when multiple layers of composite components render to the same null placeholder
1405
* works when switching components
1406
+* can render null at the top level
1407
* does not break when updating during mount
1408
* preserves the dom node during updates
1409
src/renderers/shared/shared/__tests__/ReactEmptyComponent-test.js
+12
-6
@@ -246,14 +246,20 @@ describe('ReactEmptyComponent', () => {
246
expect(assertions).toBe(3);
247
});
248
249
- it('throws when rendering null at the top level', () => {
250
- // TODO: This should actually work since `null` is a valid ReactNode
249
+ it('can render null at the top level', () => {
250
var div = document.createElement('div');
252
- expect(function() {
251
+
252
+ if (ReactDOMFeatureFlags.useFiber) {
253
ReactDOM.render(null, div);
254
- }).toThrowError(
255
- 'ReactDOM.render(): Invalid component element.'
256
- );
254
+ expect(div.innerHTML).toBe('');
255
+ } else {
256
+ // Stack does not implement this.
257
+ expect(function() {
258
+ ReactDOM.render(null, div);
259
+ }).toThrowError(
260
+ 'ReactDOM.render(): Invalid component element.'
261
+ );
262
+ }
263
});
264
265
it('does not break when updating during mount', () => {