diff --git a/src/vueWrapper.ts b/src/vueWrapper.ts index b398e12af..f0d2b5f0c 100644 --- a/src/vueWrapper.ts +++ b/src/vueWrapper.ts @@ -74,19 +74,19 @@ export class VueWrapper< const checkTree = (subTree: VNode): boolean => { // if the subtree is an array of children, we have multiple root nodes if (subTree.shapeFlag === ShapeFlags.ARRAY_CHILDREN) return true - if ( subTree.shapeFlag & ShapeFlags.STATEFUL_COMPONENT || subTree.shapeFlag & ShapeFlags.FUNCTIONAL_COMPONENT ) { - // Component has multiple children or slot with multiple children - if (subTree.shapeFlag & ShapeFlags.ARRAY_CHILDREN) { - return true - } - + // We are rendering other component, check it's tree instead if (subTree.component?.subTree) { return checkTree(subTree.component.subTree) } + + // Component has multiple children + if (subTree.shapeFlag & ShapeFlags.ARRAY_CHILDREN) { + return true + } } return false diff --git a/tests/element.spec.ts b/tests/element.spec.ts index 5e77ac720..d164caac0 100644 --- a/tests/element.spec.ts +++ b/tests/element.spec.ts @@ -105,4 +105,14 @@ describe('element', () => { '
foo
bar
baz
' ) }) + + it('returns correct element for component which renders other component with array of vnodes in default slot', () => { + const Nested = { + template: '
' + } + const Root = () => h(Nested, {}, [h('div', {}, 'foo'), h('div', {}, 'bar')]) + + const wrapper = mount(Root) + expect(wrapper.element.innerHTML).toBe('
foo
bar
') + }) })