feat(ct): solid default child (#16839)
This commit is contained in:
parent
c3f39faefc
commit
996468d4b7
|
|
@ -54,7 +54,10 @@ function render(component) {
|
|||
if (component.kind !== 'jsx')
|
||||
throw new Error('Object mount notation is not supported');
|
||||
|
||||
return createComponent(componentFunc, component.props);
|
||||
return createComponent(componentFunc, {
|
||||
children: component.children,
|
||||
...component.props
|
||||
});
|
||||
}
|
||||
|
||||
const unmountKey = Symbol('disposeKey');
|
||||
|
|
|
|||
15
tests/components/ct-solid/src/components/DefaultChildren.tsx
Normal file
15
tests/components/ct-solid/src/components/DefaultChildren.tsx
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
type DefaultChildrenProps = {
|
||||
children?: any;
|
||||
}
|
||||
|
||||
export default function DefaultChildren(props: DefaultChildrenProps) {
|
||||
return <div>
|
||||
<h1>Welcome!</h1>
|
||||
<main>
|
||||
{props.children}
|
||||
</main>
|
||||
<footer>
|
||||
Thanks for visiting.
|
||||
</footer>
|
||||
</div>
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import { test, expect } from '@playwright/experimental-ct-solid'
|
||||
import Button from './components/Button';
|
||||
import DefaultChildren from './components/DefaultChildren';
|
||||
import MultiRoot from './components/MultiRoot';
|
||||
|
||||
test.use({ viewport: { width: 500, height: 500 } });
|
||||
|
|
@ -16,7 +17,14 @@ test('callback should work', async ({ mount }) => {
|
|||
}}></Button>)
|
||||
await component.click()
|
||||
expect(messages).toEqual(['hello'])
|
||||
});
|
||||
})
|
||||
|
||||
test('default child should work', async ({ mount }) => {
|
||||
const component = await mount(<DefaultChildren>
|
||||
Main Content
|
||||
</DefaultChildren>)
|
||||
await expect(component).toContainText('Main Content')
|
||||
})
|
||||
|
||||
test('should unmount', async ({ page, mount }) => {
|
||||
const component = await mount(<Button title="Submit" />)
|
||||
|
|
|
|||
Loading…
Reference in a new issue