Add tests for rendering null and undefined in RSC (#43768)
This commit is contained in:
parent
738de0164f
commit
08d270cdeb
13 changed files with 73 additions and 0 deletions
|
@ -64,6 +64,45 @@ describe('app dir - rsc basics', () => {
|
|||
return
|
||||
}
|
||||
|
||||
it('should correctly render page returning null', async () => {
|
||||
const homeHTML = await renderViaHTTP(next.url, '/return-null/page')
|
||||
const $ = cheerio.load(homeHTML)
|
||||
expect($('#return-null-layout').html()).toBeEmpty()
|
||||
})
|
||||
|
||||
it('should correctly render component returning null', async () => {
|
||||
const homeHTML = await renderViaHTTP(next.url, '/return-null/component')
|
||||
const $ = cheerio.load(homeHTML)
|
||||
expect($('#return-null-layout').html()).toBeEmpty()
|
||||
})
|
||||
|
||||
it('should correctly render layout returning null', async () => {
|
||||
const homeHTML = await renderViaHTTP(next.url, '/return-null/layout')
|
||||
const $ = cheerio.load(homeHTML)
|
||||
expect($('#return-null-layout').html()).toBeEmpty()
|
||||
})
|
||||
|
||||
it('should correctly render page returning undefined', async () => {
|
||||
const homeHTML = await renderViaHTTP(next.url, '/return-undefined/page')
|
||||
const $ = cheerio.load(homeHTML)
|
||||
expect($('#return-undefined-layout').html()).toBeEmpty()
|
||||
})
|
||||
|
||||
it('should correctly render component returning undefined', async () => {
|
||||
const homeHTML = await renderViaHTTP(
|
||||
next.url,
|
||||
'/return-undefined/component'
|
||||
)
|
||||
const $ = cheerio.load(homeHTML)
|
||||
expect($('#return-undefined-layout').html()).toBeEmpty()
|
||||
})
|
||||
|
||||
it('should correctly render layout returning undefined', async () => {
|
||||
const homeHTML = await renderViaHTTP(next.url, '/return-undefined/layout')
|
||||
const $ = cheerio.load(homeHTML)
|
||||
expect($('#return-undefined-layout').html()).toBeEmpty()
|
||||
})
|
||||
|
||||
it('should render server components correctly', async () => {
|
||||
const homeHTML = await renderViaHTTP(next.url, '/', null, {
|
||||
headers: {
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
export default function Component() {
|
||||
return null
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
import Component from './component'
|
||||
|
||||
export default function Page() {
|
||||
return <Component />
|
||||
}
|
3
test/e2e/app-dir/rsc-basic/app/return-null/layout.js
Normal file
3
test/e2e/app-dir/rsc-basic/app/return-null/layout.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
export default function Layout({ children }) {
|
||||
return <div id="return-null-layout">{children}</div>
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
export default function Layout() {
|
||||
return null
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
export default function Page() {
|
||||
return <div />
|
||||
}
|
3
test/e2e/app-dir/rsc-basic/app/return-null/page/page.js
Normal file
3
test/e2e/app-dir/rsc-basic/app/return-null/page/page.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
export default function Page() {
|
||||
return null
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
export default function Component() {}
|
|
@ -0,0 +1,5 @@
|
|||
import Component from './component'
|
||||
|
||||
export default function Page() {
|
||||
return <Component />
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
export default function Layout({ children }) {
|
||||
return <div id="return-undefined-layout">{children}</div>
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
export default function Layout() {}
|
|
@ -0,0 +1,3 @@
|
|||
export default function Page() {
|
||||
return <div />
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
export default function Page() {}
|
Loading…
Reference in a new issue