Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(find): extend tests with deep nested multiple roots #1569

Merged
merged 1 commit into from Jun 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
60 changes: 60 additions & 0 deletions tests/find.spec.ts
Expand Up @@ -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: `
<span>Text 1</span>
<span>Text 2</span>
<ReturnSlot>
<span>Text 3</span>
</ReturnSlot>
`
})
const MultiRootComponent = defineComponent({
components: { NestedMultiRootComponent },
template: `
<span>Text 4</span>
<span>Text 5</span>
<NestedMultiRootComponent />
`
})

const Component = defineComponent({
components: { ReturnSlot, MultiRootComponent },
template: `
<span>Text 6</span>
<ReturnSlot>
<span>Text 7</span>
<ReturnSlot>
<span>Text 8</span>
<span>Text 9</span>
<MultiRootComponent />
</ReturnSlot>
</ReturnSlot>
`
})

const wrapper = mount(Component)
expect(wrapper.findAll('span')).toHaveLength(9)
})
})

// https://github.com/vuejs/test-utils/issues/1233
Expand Down