From 400af9e80cc7b6ecf46a75527dabb8db4c33925a Mon Sep 17 00:00:00 2001 From: freakzlike Date: Fri, 3 Jun 2022 17:37:01 +0200 Subject: [PATCH] chore(find): extend tests with deep nested multiple roots --- tests/find.spec.ts | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tests/find.spec.ts b/tests/find.spec.ts index c54dc091b..fff675b93 100644 --- a/tests/find.spec.ts +++ b/tests/find.spec.ts @@ -334,6 +334,66 @@ describe('findAll', () => { const wrapper = mount(MultipleRootRender) expect(wrapper.findAll('a')).toHaveLength(3) }) + + it('finds all with nested roots inside render function', () => { + const wrapper = mount({ + render() { + return [ + h('span', 'Text 1'), + [ + h('span', 'Text 2'), + h('span', 'Text 3'), + [h('span', 'Text 4'), h('span', 'Text 5')] + ] + ] + } + }) + expect(wrapper.findAll('span')).toHaveLength(5) + }) + + it('finds all deep nested root nodes', () => { + const ReturnSlot = defineComponent({ + render() { + return this.$slots.default!({}) + } + }) + const NestedMultiRootComponent = defineComponent({ + components: { ReturnSlot }, + template: ` + Text 1 + Text 2 + + Text 3 + + ` + }) + const MultiRootComponent = defineComponent({ + components: { NestedMultiRootComponent }, + template: ` + Text 4 + Text 5 + + ` + }) + + const Component = defineComponent({ + components: { ReturnSlot, MultiRootComponent }, + template: ` + Text 6 + + Text 7 + + Text 8 + Text 9 + + + + ` + }) + + const wrapper = mount(Component) + expect(wrapper.findAll('span')).toHaveLength(9) + }) }) // https://github.com/vuejs/test-utils/issues/1233