1
0
Fork 0
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:
Arunoda Susiripala 2017-04-27 08:39:52 -07:00
parent 7fcd1ea760
commit 753113bb9c
5 changed files with 36 additions and 0 deletions

View file

@ -0,0 +1,3 @@
export default () => (
<p>Hello World 1</p>
)

View file

@ -0,0 +1,8 @@
import dynamic from 'next/dynamic'
const Hello = dynamic(import('../../components/hello1'), {
ssr: false,
loading: () => (<p>LOADING</p>)
})
export default Hello

View file

@ -0,0 +1,5 @@
import dynamic from 'next/dynamic'
const Hello = dynamic(import('../../components/hello1'), { ssr: false })
export default Hello

View file

@ -0,0 +1,5 @@
import dynamic from 'next/dynamic'
const Hello = dynamic(import('../../components/hello1'))
export default Hello

View file

@ -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')
})
}) })
} }