Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/test-utils/src/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@ export default class Wrapper implements BaseWrapper {
if (!this.vnode) {
return this.element.innerHTML === ''
}
if (this.vnode.children) {
return this.vnode.children.every(vnode => vnode.isComment)
}
return this.vnode.children === undefined || this.vnode.children.length === 0
}

Expand Down
6 changes: 6 additions & 0 deletions test/specs/wrapper/isEmpty.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ describeWithShallowAndMount('isEmpty', (mountingMethod) => {
expect(wrapper.isEmpty()).to.equal(true)
})

it('returns true if node contains comment', () => {
const compiled = compileToFunctions('<div><div v-if="false"></div></div>')
const wrapper = mountingMethod(compiled)
expect(wrapper.isEmpty()).to.equal(true)
})

it('returns true if innerHTML is empty', () => {
const TestComponent = {
render (createElement) {
Expand Down