From 3ec1779837c4bccbcfb7239b80abc45edd2c7134 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Wed, 28 Dec 2016 00:46:23 +0000 Subject: [PATCH] Make test that forbids arrays Stack-only --- .../__tests__/ReactStatelessComponent-test.js | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/renderers/shared/shared/__tests__/ReactStatelessComponent-test.js b/src/renderers/shared/shared/__tests__/ReactStatelessComponent-test.js index caea83e35e..a095ee0ca4 100644 --- a/src/renderers/shared/shared/__tests__/ReactStatelessComponent-test.js +++ b/src/renderers/shared/shared/__tests__/ReactStatelessComponent-test.js @@ -15,6 +15,8 @@ var React; var ReactDOM; var ReactTestUtils; +var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags'); + function StatelessComponent(props) { return
{props.name}
; } @@ -123,17 +125,20 @@ describe('ReactStatelessComponent', () => { ); }); - it('should throw when stateless component returns array', () => { - function NotAComponent() { - return [
,
]; - } - expect(function() { - ReactTestUtils.renderIntoDocument(
); - }).toThrowError( - 'NotAComponent(...): A valid React element (or null) must be returned. ' + - 'You may have returned undefined, an array or some other invalid object.' - ); - }); + if (!ReactDOMFeatureFlags.useFiber) { + // Stack doesn't support fragments + it('should throw when stateless component returns array', () => { + function NotAComponent() { + return [
,
]; + } + expect(function() { + ReactTestUtils.renderIntoDocument(
); + }).toThrowError( + 'NotAComponent(...): A valid React element (or null) must be returned. ' + + 'You may have returned undefined, an array or some other invalid object.' + ); + }); + } it('should throw when stateless component returns undefined', () => { function NotAComponent() {