Skip to content

Commit 92c3f71

Browse files
authored
test: test that $root emitted an event (#1078)
1 parent a0528ca commit 92c3f71

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Diff for: test/specs/wrapper/emitted.spec.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createLocalVue } from '~vue/test-utils'
1+
import { createLocalVue, createWrapper } from '~vue/test-utils'
22
import { describeWithShallowAndMount, vueVersion } from '~resources/utils'
33
import { itDoNotRunIf } from 'conditional-specs'
44
import Vue from 'vue'
@@ -158,4 +158,14 @@ describeWithShallowAndMount('emitted', mountingMethod => {
158158

159159
expect(wrapper.find({ name: 'bar' }).emitted('foo')).to.exist
160160
})
161+
162+
it('captures emitted events on $root instance', () => {
163+
const wrapper = mountingMethod({
164+
render: h => h('div')
165+
})
166+
167+
wrapper.vm.$root.$emit('foo')
168+
const rootWrapper = createWrapper(wrapper.vm.$root)
169+
expect(rootWrapper.emitted('foo')).to.exist
170+
})
161171
})

0 commit comments

Comments
 (0)