Skip to content

Commit

Permalink
Allow components to render undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhanlonii committed Jul 13, 2021
1 parent bfa50f8 commit 8e9173d
Show file tree
Hide file tree
Showing 10 changed files with 286 additions and 416 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -924,33 +924,37 @@ describe('ReactDOMServerIntegration', () => {
);
});

describe('components that throw errors', function() {
itThrowsWhenRendering(
'a function returning undefined',
async render => {
const UndefinedComponent = () => undefined;
await render(<UndefinedComponent />, 1);
},
'UndefinedComponent(...): Nothing was returned from render. ' +
'This usually means a return statement is missing. Or, to ' +
'render nothing, return null.',
);
describe('components that render nullish', function() {
itRenders('a function returning null', async render => {
const NullComponent = () => null;
await render(<NullComponent />);
});

itThrowsWhenRendering(
'a class returning undefined',
async render => {
class UndefinedComponent extends React.Component {
render() {
return undefined;
}
itRenders('a class returning null', async render => {
class NullComponent extends React.Component {
render() {
return null;
}
await render(<UndefinedComponent />, 1);
},
'UndefinedComponent(...): Nothing was returned from render. ' +
'This usually means a return statement is missing. Or, to ' +
'render nothing, return null.',
);
}
await render(<NullComponent />);
});

itRenders('a function returning undefined', async render => {
const UndefinedComponent = () => undefined;
await render(<UndefinedComponent />);
});

itRenders('a class returning undefined', async render => {
class UndefinedComponent extends React.Component {
render() {
return undefined;
}
}
await render(<UndefinedComponent />);
});
});

describe('components that throw errors', function() {
itThrowsWhenRendering(
'a function returning an object',
async render => {
Expand Down
Loading

0 comments on commit 8e9173d

Please sign in to comment.