Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/__tests__/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => <div>foo</div>), 100),
),
LoadingComponent,
})
const Comp = ({ compKey }) => (
<div>{compKey ? <AsyncComponent key={compKey} /> : null}</div>
)
const wrapper = mount(<Comp compKey="1" />)
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', () => {
Expand Down
1 change: 0 additions & 1 deletion src/asyncComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down