mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Make test that forbids arrays Stack-only
This commit is contained in:
committed by
Andrew Clark
parent
df0532b0c3
commit
3ec1779837
@@ -15,6 +15,8 @@ var React;
|
||||
var ReactDOM;
|
||||
var ReactTestUtils;
|
||||
|
||||
var ReactDOMFeatureFlags = require('ReactDOMFeatureFlags');
|
||||
|
||||
function StatelessComponent(props) {
|
||||
return <div>{props.name}</div>;
|
||||
}
|
||||
@@ -123,17 +125,20 @@ describe('ReactStatelessComponent', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw when stateless component returns array', () => {
|
||||
function NotAComponent() {
|
||||
return [<div />, <div />];
|
||||
}
|
||||
expect(function() {
|
||||
ReactTestUtils.renderIntoDocument(<div><NotAComponent /></div>);
|
||||
}).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 [<div />, <div />];
|
||||
}
|
||||
expect(function() {
|
||||
ReactTestUtils.renderIntoDocument(<div><NotAComponent /></div>);
|
||||
}).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() {
|
||||
|
||||
Reference in New Issue
Block a user