Unverified Commit 86547db9 authored by Janka Uryga's avatar Janka Uryga Committed by GitHub

test: both wrapped and unwrapped dynamic() (#69780)

We should be testing both usage patterns, i.e. returning a component
wrapped in a `{ default: ... }` and just a bare component.

Note that the behavior here will partially change in 15, so this test is
just so that we can avoid regressing in 14.x.
parent a882e6e9
'use client'
export function Button(props) {
return <button {...props} />
}
import dynamic from 'next/dynamic'
const Button = dynamic(() =>
import('./client').then((mod) => {
return mod.Button
})
)
export default function Page() {
return <Button id="client-button">this is a client button</Button>
}
...@@ -2,7 +2,7 @@ import dynamic from 'next/dynamic' ...@@ -2,7 +2,7 @@ import dynamic from 'next/dynamic'
const Button = dynamic(() => const Button = dynamic(() =>
import('./client').then((mod) => { import('./client').then((mod) => {
return mod.Button return { default: mod.Button }
}) })
) )
......
...@@ -58,6 +58,11 @@ createNextDescribe( ...@@ -58,6 +58,11 @@ createNextDescribe(
expect($('h1').text()).toBe('hello') expect($('h1').text()).toBe('hello')
}) })
it('14.x behavior: should support dynamic import that returns a client component not wrapped in a module', async () => {
const $ = await next.render$('/dynamic/named-export-unwrapped')
expect($('#client-button').text()).toBe('this is a client button')
})
describe('no SSR', () => { describe('no SSR', () => {
it('should not render client component imported through ssr: false in client components in edge runtime', async () => { it('should not render client component imported through ssr: false in client components in edge runtime', async () => {
// noSSR should not show up in html // noSSR should not show up in html
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment