Skip to content

Commit 753113b

Browse files
committed
Add some tests for dynamic rendering.
1 parent 7fcd1ea commit 753113b

File tree

5 files changed

+36
-0
lines changed

5 files changed

+36
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default () => (
2+
<p>Hello World 1</p>
3+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import dynamic from 'next/dynamic'
2+
3+
const Hello = dynamic(import('../../components/hello1'), {
4+
ssr: false,
5+
loading: () => (<p>LOADING</p>)
6+
})
7+
8+
export default Hello
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import dynamic from 'next/dynamic'
2+
3+
const Hello = dynamic(import('../../components/hello1'), { ssr: false })
4+
5+
export default Hello
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import dynamic from 'next/dynamic'
2+
3+
const Hello = dynamic(import('../../components/hello1'))
4+
5+
export default Hello

test/integration/basic/test/rendering.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,20 @@ export default function ({ app }, suiteName, render) {
7474
expect($('h1').text()).toBe('404')
7575
expect($('h2').text()).toBe('This page could not be found.')
7676
})
77+
78+
test('render dynmaic import components via SSR', async () => {
79+
const $ = await get$('/dynamic/ssr')
80+
expect($('p').text()).toBe('Hello World 1')
81+
})
82+
83+
test('stop render dynmaic import components in SSR', async () => {
84+
const $ = await get$('/dynamic/no-ssr')
85+
expect($('p').text()).toBe('loading...')
86+
})
87+
88+
test('stop render dynmaic import components in SSR with custom loading', async () => {
89+
const $ = await get$('/dynamic/no-ssr-custom-loading')
90+
expect($('p').text()).toBe('LOADING')
91+
})
7792
})
7893
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy