Skip to content

Commit

Permalink
feat(react): the loader will not try to load an empty src (#186)
Browse files Browse the repository at this point in the history
Closes #150
  • Loading branch information
clebert authored Dec 14, 2018
1 parent f04693c commit 236c487
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/react/src/__tests__/feature-app-loader.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,16 @@ describe('FeatureAppLoader', () => {
spyConsoleError.mockRestore();
});

it('throws an error if no src is provided', () => {
expect(() =>
shallow(<FeatureAppLoader manager={mockManager} src="" />)
).toThrowError(new Error('No src provided.'));
});

it('initially renders nothing', () => {
const wrapper = shallow(<FeatureAppLoader manager={mockManager} src="" />);
const wrapper = shallow(
<FeatureAppLoader manager={mockManager} src="/test.js" />
);

expect(wrapper.isEmptyRender()).toBe(true);
});
Expand Down
4 changes: 4 additions & 0 deletions packages/react/src/feature-app-loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export class FeatureAppLoader extends React.PureComponent<
const src = inBrowser ? browserSrc : nodeSrc;

if (!src) {
if (inBrowser) {
throw new Error('No src provided.');
}

return;
}

Expand Down

0 comments on commit 236c487

Please sign in to comment.