mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Add some tests for dynamic rendering.
This commit is contained in:
parent
7fcd1ea760
commit
753113bb9c
3
test/integration/basic/components/hello1.js
Normal file
3
test/integration/basic/components/hello1.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export default () => (
|
||||||
|
<p>Hello World 1</p>
|
||||||
|
)
|
|
@ -0,0 +1,8 @@
|
||||||
|
import dynamic from 'next/dynamic'
|
||||||
|
|
||||||
|
const Hello = dynamic(import('../../components/hello1'), {
|
||||||
|
ssr: false,
|
||||||
|
loading: () => (<p>LOADING</p>)
|
||||||
|
})
|
||||||
|
|
||||||
|
export default Hello
|
5
test/integration/basic/pages/dynamic/no-ssr.js
Normal file
5
test/integration/basic/pages/dynamic/no-ssr.js
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
import dynamic from 'next/dynamic'
|
||||||
|
|
||||||
|
const Hello = dynamic(import('../../components/hello1'), { ssr: false })
|
||||||
|
|
||||||
|
export default Hello
|
5
test/integration/basic/pages/dynamic/ssr.js
Normal file
5
test/integration/basic/pages/dynamic/ssr.js
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
import dynamic from 'next/dynamic'
|
||||||
|
|
||||||
|
const Hello = dynamic(import('../../components/hello1'))
|
||||||
|
|
||||||
|
export default Hello
|
|
@ -74,5 +74,20 @@ export default function ({ app }, suiteName, render) {
|
||||||
expect($('h1').text()).toBe('404')
|
expect($('h1').text()).toBe('404')
|
||||||
expect($('h2').text()).toBe('This page could not be found.')
|
expect($('h2').text()).toBe('This page could not be found.')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('render dynmaic import components via SSR', async () => {
|
||||||
|
const $ = await get$('/dynamic/ssr')
|
||||||
|
expect($('p').text()).toBe('Hello World 1')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('stop render dynmaic import components in SSR', async () => {
|
||||||
|
const $ = await get$('/dynamic/no-ssr')
|
||||||
|
expect($('p').text()).toBe('loading...')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('stop render dynmaic import components in SSR with custom loading', async () => {
|
||||||
|
const $ = await get$('/dynamic/no-ssr-custom-loading')
|
||||||
|
expect($('p').text()).toBe('LOADING')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue