diff --git a/packages/test-utils/src/set-watchers-to-sync.js b/packages/test-utils/src/set-watchers-to-sync.js index 93fd85d7a..7577a1515 100644 --- a/packages/test-utils/src/set-watchers-to-sync.js +++ b/packages/test-utils/src/set-watchers-to-sync.js @@ -1,3 +1,5 @@ +import { VUE_VERSION } from './consts' + function setDepsSync (dep) { dep.subs.forEach(setWatcherSync) } @@ -24,4 +26,16 @@ export function setWatchersToSync (vm) { setWatcherSync(vm._watcher) vm.$children.forEach(setWatchersToSync) + + if (!vm.$_vueTestUtils_update) { + vm.$_vueTestUtils_update = vm._update + vm._update = function (vnode, hydrating) { + this.$_vueTestUtils_update(vnode, hydrating) + if (VUE_VERSION >= 2.1 && this._isMounted && this.$options.updated) { + this.$options.updated.forEach((handler) => { + handler.call(this) + }) + } + } + } } diff --git a/test/specs/mounting-options/sync.spec.js b/test/specs/mounting-options/sync.spec.js index d387351e0..7426d1ce4 100644 --- a/test/specs/mounting-options/sync.spec.js +++ b/test/specs/mounting-options/sync.spec.js @@ -1,3 +1,4 @@ +import sinon from 'sinon' import { describeWithShallowAndMount } from '~resources/utils' describeWithShallowAndMount('options.sync', (mountingMethod) => { @@ -46,7 +47,7 @@ describeWithShallowAndMount('options.sync', (mountingMethod) => {
computed.text: {{ computedText }}- + `, data () { return { @@ -110,4 +111,25 @@ describeWithShallowAndMount('options.sync', (mountingMethod) => { done() }) }) + + it('call updated when sync is not false', () => { + const spy = sinon.stub() + const TestComponent = { + template: '