diff --git a/src/__tests__/integration.test.js b/src/__tests__/integration.test.js index 97de90b..4c6e7eb 100644 --- a/src/__tests__/integration.test.js +++ b/src/__tests__/integration.test.js @@ -193,6 +193,28 @@ describe('integration tests', () => { const wrapper = mount(app) expect(wrapper.html()).toContain('Loading...') }) + + it('renders the LoadingComponent without bootstrapper', async () => { + const AsyncComponent = asyncComponent({ + resolve: () => + new Promise(resolve => + setTimeout(() => resolve(() =>
foo
), 100), + ), + LoadingComponent, + }) + const Comp = ({ compKey }) => ( +
{compKey ? : null}
+ ) + const wrapper = mount() + expect(wrapper.html()).toContain('Loading...') + // Unmount the component immediately + wrapper.setProps({ + compKey: '2', + }) + expect(wrapper.html()).toContain('Loading...') + await new Promise(resolve => setTimeout(resolve, 150)) + expect(wrapper.html()).not.toContain('Loading...') + }) }) describe('server rendering', () => { diff --git a/src/asyncComponent.js b/src/asyncComponent.js index 4859240..f992164 100644 --- a/src/asyncComponent.js +++ b/src/asyncComponent.js @@ -44,7 +44,6 @@ export default function asyncComponent(config) { const needToResolveOnBrowser = () => state.module == null && state.error == null && - !state.resolving && typeof window !== 'undefined' // Takes the given module and if it has a ".default" the ".default" will