From 92c3f712d49e0cb774dde87cfef639f923230ce6 Mon Sep 17 00:00:00 2001 From: Edd Yerburgh Date: Mon, 24 Dec 2018 06:14:48 +0000 Subject: [PATCH] test: test that $root emitted an event (#1078) --- test/specs/wrapper/emitted.spec.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/specs/wrapper/emitted.spec.js b/test/specs/wrapper/emitted.spec.js index 681176458..62def285a 100644 --- a/test/specs/wrapper/emitted.spec.js +++ b/test/specs/wrapper/emitted.spec.js @@ -1,4 +1,4 @@ -import { createLocalVue } from '~vue/test-utils' +import { createLocalVue, createWrapper } from '~vue/test-utils' import { describeWithShallowAndMount, vueVersion } from '~resources/utils' import { itDoNotRunIf } from 'conditional-specs' import Vue from 'vue' @@ -158,4 +158,14 @@ describeWithShallowAndMount('emitted', mountingMethod => { expect(wrapper.find({ name: 'bar' }).emitted('foo')).to.exist }) + + it('captures emitted events on $root instance', () => { + const wrapper = mountingMethod({ + render: h => h('div') + }) + + wrapper.vm.$root.$emit('foo') + const rootWrapper = createWrapper(wrapper.vm.$root) + expect(rootWrapper.emitted('foo')).to.exist + }) })