mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-03 07:51:12 +03:00
fix(ct): solid and react JS as child (#20125)
This commit is contained in:
parent
0b300f455c
commit
d58d833daf
@ -36,9 +36,11 @@ export function register(components) {
|
||||
|
||||
/**
|
||||
* @param {Component} component
|
||||
* @returns {JSX.Element}
|
||||
*/
|
||||
function render(component) {
|
||||
if (typeof component !== 'object' || Array.isArray(component))
|
||||
return component;
|
||||
|
||||
let componentFunc = registry.get(component.type);
|
||||
if (!componentFunc) {
|
||||
// Lookup by shorthand.
|
||||
|
@ -42,7 +42,7 @@ function createChild(child) {
|
||||
* @param {Component} component
|
||||
*/
|
||||
function createComponent(component) {
|
||||
if (typeof component === 'string')
|
||||
if (typeof component !== 'object' || Array.isArray(component))
|
||||
return component;
|
||||
|
||||
let Component = registry.get(component.type);
|
||||
|
@ -34,7 +34,7 @@ export type ObjectComponent = {
|
||||
options?: MountOptions
|
||||
};
|
||||
|
||||
export type Component = JsxComponent | ObjectComponent;
|
||||
export type Component = JsxComponent | ObjectComponent | number | string | Array<any>;
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
|
@ -42,3 +42,18 @@ test('render named children', async ({ mount }) => {
|
||||
await expect(component).toContainText('Main Content');
|
||||
await expect(component).toContainText('Footer');
|
||||
});
|
||||
|
||||
test('render string as child', async ({ mount }) => {
|
||||
const component = await mount(<DefaultChildren>{'string'}</DefaultChildren>);
|
||||
await expect(component).toContainText('string');
|
||||
});
|
||||
|
||||
test('render array as child', async ({ mount }) => {
|
||||
const component = await mount(<DefaultChildren>{[4,2]}</DefaultChildren>);
|
||||
await expect(component).toContainText('42');
|
||||
});
|
||||
|
||||
test('render number as child', async ({ mount }) => {
|
||||
const component = await mount(<DefaultChildren>{1337}</DefaultChildren>);
|
||||
await expect(component).toContainText('1337');
|
||||
});
|
||||
|
@ -42,3 +42,18 @@ test('render named children', async ({ mount }) => {
|
||||
await expect(component).toContainText('Main Content');
|
||||
await expect(component).toContainText('Footer');
|
||||
});
|
||||
|
||||
test('render string as child', async ({ mount }) => {
|
||||
const component = await mount(<DefaultChildren>{'string'}</DefaultChildren>);
|
||||
await expect(component).toContainText('string');
|
||||
});
|
||||
|
||||
test('render array as child', async ({ mount }) => {
|
||||
const component = await mount(<DefaultChildren>{[4,2]}</DefaultChildren>);
|
||||
await expect(component).toContainText('42');
|
||||
});
|
||||
|
||||
test('render number as child', async ({ mount }) => {
|
||||
const component = await mount(<DefaultChildren>{1337}</DefaultChildren>);
|
||||
await expect(component).toContainText('1337');
|
||||
});
|
||||
|
@ -42,3 +42,18 @@ test('render named children', async ({ mount }) => {
|
||||
await expect(component).toContainText('Main Content');
|
||||
await expect(component).toContainText('Footer');
|
||||
});
|
||||
|
||||
test('render string as child', async ({ mount }) => {
|
||||
const component = await mount(<DefaultChildren>{'string'}</DefaultChildren>);
|
||||
await expect(component).toContainText('string');
|
||||
});
|
||||
|
||||
test('render array as child', async ({ mount }) => {
|
||||
const component = await mount(<DefaultChildren>{[4,2]}</DefaultChildren>);
|
||||
await expect(component).toContainText('42');
|
||||
});
|
||||
|
||||
test('render number as child', async ({ mount }) => {
|
||||
const component = await mount(<DefaultChildren>{1337}</DefaultChildren>);
|
||||
await expect(component).toContainText('1337');
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user