Skip to content

Commit

Permalink
Move test
Browse files Browse the repository at this point in the history
  • Loading branch information
devknoll committed Nov 7, 2021
1 parent 198c402 commit 0600dfe
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 19 deletions.
@@ -1,2 +1,3 @@
import { createContext } from 'react'

export default createContext(null)
@@ -0,0 +1,20 @@
import { Html, Head, Main, NextScript } from 'next/document'
import Context from '../lib/context'

export default function Document() {
return (
<Html>
<Head />
<body>
<Main>
{(children) => (
<Context.Provider value="from render prop">
{children}
</Context.Provider>
)}
</Main>
<NextScript />
</body>
</Html>
)
}
@@ -1,7 +1,7 @@
import { useContext } from 'react'
import Context from '../components/context'
import Context from '../lib/context'

export default function MainRenderProp() {
const value = useContext(Context)
return value
return <span>{value}</span>
}
@@ -0,0 +1,24 @@
/* eslint-env jest */

import { join } from 'path'
import { findPort, launchApp, killApp, renderViaHTTP } from 'next-test-utils'

const appDir = join(__dirname, '..')
let appPort
let app

describe('Functional Custom Document', () => {
describe('development mode', () => {
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(appDir, appPort)
})

afterAll(() => killApp(app))

it('supports render props', async () => {
const html = await renderViaHTTP(appPort, '/')
expect(html).toMatch(/<span>from render prop<\/span>/)
})
})
})
9 changes: 1 addition & 8 deletions test/integration/react-18/app/pages/_document.js
@@ -1,18 +1,11 @@
import { Html, Head, Main, NextScript } from 'next/document'
import Context from '../components/context'

export default function Document() {
return (
<Html>
<Head />
<body>
<Main>
{(content) => (
<Context.Provider value="from main render prop">
{content}
</Context.Provider>
)}
</Main>
<Main />
<NextScript />
</body>
</Html>
Expand Down
9 changes: 0 additions & 9 deletions test/integration/react-18/test/index.test.js
Expand Up @@ -134,15 +134,6 @@ describe('Basics', () => {
'A React component suspended while rendering, but no fallback UI was specified'
)
})

it('supports render prop as children in <Main />', async () => {
const appPort = await findPort()
const app = await launchApp(appDir, appPort, { nodeArgs })
const html = await renderViaHTTP(appPort, '/main-render-prop')
await killApp(app)

expect(html).toContain('from main render prop')
})
})

describe('Blocking mode', () => {
Expand Down

0 comments on commit 0600dfe

Please sign in to comment.