Make test that forbids arrays Stack-only
Dan Abramov committed
Dec 28, 2016 at 00:46 UTC
3ec1779837c4bccbcfb7239b80abc45edd2c7134
1 file changed
+16
-11
src/renderers/shared/shared/__tests__/ReactStatelessComponent-test.js
+16
-11
@@ -15,6 +15,8 @@ var React;
15
var ReactDOM;
16
var ReactTestUtils;
17
18
+var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
19
+
20
function StatelessComponent(props) {
21
return <div>{props.name}</div>;
22
}
@@ -123,17 +125,20 @@ describe('ReactStatelessComponent', () => {
125
);
126
});
127
126
- it('should throw when stateless component returns array', () => {
127
- function NotAComponent() {
128
- return [<div />, <div />];
129
- }
130
- expect(function() {
131
- ReactTestUtils.renderIntoDocument(<div><NotAComponent /></div>);
132
- }).toThrowError(
133
- 'NotAComponent(...): A valid React element (or null) must be returned. ' +
134
- 'You may have returned undefined, an array or some other invalid object.'
135
- );
136
- });
128
+ if (!ReactDOMFeatureFlags.useFiber) {
129
+ // Stack doesn't support fragments
130
+ it('should throw when stateless component returns array', () => {
131
+ function NotAComponent() {
132
+ return [<div />, <div />];
133
+ }
134
+ expect(function() {
135
+ ReactTestUtils.renderIntoDocument(<div><NotAComponent /></div>);
136
+ }).toThrowError(
137
+ 'NotAComponent(...): A valid React element (or null) must be returned. ' +
138
+ 'You may have returned undefined, an array or some other invalid object.'
139
+ );
140
+ });
141
+ }
142
143
it('should throw when stateless component returns undefined', () => {
144
function NotAComponent() {