mirror of
				https://github.com/microsoft/playwright.git
				synced 2025-06-26 21:40:17 +00:00 
			
		
		
		
	fix(ct): solid render array as child (#27715)
This commit is contained in:
		
							parent
							
								
									6fe31ab52c
								
							
						
					
					
						commit
						27daa5e7b1
					
				@ -92,6 +92,8 @@ function __pwCreateComponent(component) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  const children = component.children.reduce((/** @type {any[]} */ children, current) => {
 | 
					  const children = component.children.reduce((/** @type {any[]} */ children, current) => {
 | 
				
			||||||
    const child = __pwCreateChild(current);
 | 
					    const child = __pwCreateChild(current);
 | 
				
			||||||
 | 
					    if (Array.isArray(child))
 | 
				
			||||||
 | 
					      return child.map(grandChild => __pwCreateChild(grandChild));
 | 
				
			||||||
    if (typeof child !== 'string' || !!child.trim())
 | 
					    if (typeof child !== 'string' || !!child.trim())
 | 
				
			||||||
      children.push(child);
 | 
					      children.push(child);
 | 
				
			||||||
    return children;
 | 
					    return children;
 | 
				
			||||||
 | 
				
			|||||||
@ -49,8 +49,9 @@ test('render string as child', async ({ mount }) => {
 | 
				
			|||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('render array as child', async ({ mount }) => {
 | 
					test('render array as child', async ({ mount }) => {
 | 
				
			||||||
  const component = await mount(<DefaultChildren>{[4,2]}</DefaultChildren>);
 | 
					  const component = await mount(<DefaultChildren>{[<h4>{[4]}</h4>,<p>2</p>]}</DefaultChildren>);
 | 
				
			||||||
  await expect(component).toContainText('42');
 | 
					  await expect(component.getByRole('heading', { level: 4 })).toHaveText('4');
 | 
				
			||||||
 | 
					  await expect(component.getByRole('paragraph')).toHaveText('2');
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test('render number as child', async ({ mount }) => {
 | 
					test('render number as child', async ({ mount }) => {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user