Skip to content

Commit

Permalink
test: add test cases for next/dynamic and next/amp
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Apr 26, 2022
1 parent 47b967b commit 63873e2
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion test/e2e/type-module-interop/index.test.ts
Expand Up @@ -14,8 +14,13 @@ describe('Type module interop', () => {
import Link from 'next/link'
import Head from 'next/head'
import Script from 'next/script'
import dynamic from 'next/dynamic'
import { useAmp } from 'next/amp'
export default function Page() {
const Dynamic = dynamic(() => import('../components/example'))
export default function Page() {
const isAmp = useAmp()
return (
<>
<Head>
Expand All @@ -30,6 +35,8 @@ describe('Type module interop', () => {
}}
/>
<p>hello world</p>
<Dynamic />
<p id="isAmp">isAmp: {isAmp ? 'yes' : 'false'}</p>
<Link href="/modules">
<a id="link-to-module">link to module</a>
</Link>
Expand All @@ -52,6 +59,11 @@ describe('Type module interop', () => {
)
}
`,
'components/example.jsx': `
export default function Example() {
return <p>An example components load via next/dynamic</p>
}
`,
},
dependencies: {},
})
Expand All @@ -74,6 +86,11 @@ describe('Type module interop', () => {
it('should render server-side', async () => {
const html = await renderViaHTTP(next.url, '/')
expect(html).toContain('hello world')
// component load via next/dynamic should rendered on the server side
expect(html).toContain('An example components load via next/dynamic')
// imported next/amp should work on the server side
const $ = cheerio.load(html)
expect($('#isAmp').text()).toContain('no')
})

it('should render client-side', async () => {
Expand Down

0 comments on commit 63873e2

Please sign in to comment.