diff --git a/packages/test-utils/src/set-watchers-to-sync.js b/packages/test-utils/src/set-watchers-to-sync.js index 93fd85d7a..a2c52cce3 100644 --- a/packages/test-utils/src/set-watchers-to-sync.js +++ b/packages/test-utils/src/set-watchers-to-sync.js @@ -1,4 +1,5 @@ function setDepsSync (dep) { + dep.subs = dep.subs.sort((a, b) => a.id - b.id) dep.subs.forEach(setWatcherSync) } diff --git a/test/specs/wrapper/setData.spec.js b/test/specs/wrapper/setData.spec.js index d0cba10f5..0e7c50677 100644 --- a/test/specs/wrapper/setData.spec.js +++ b/test/specs/wrapper/setData.spec.js @@ -83,7 +83,35 @@ describeWithShallowAndMount('setData', (mountingMethod) => { expect(fn2).to.throw().with.property('message', message) }) - it('should not run watchers if data updated is null', () => { + it('updates watchers if computed is updated', () => { + const TestComponent = { + template: ` + {{ computedText }} + `, + data () { + return { + text: '', + basket: [] + } + }, + computed: { + computedText () { + return this.text + } + }, + watch: { + text () { + this.basket.push(this.computedText) + } + } + } + const wrapper = mountingMethod(TestComponent) + + wrapper.setData({ text: 'hello' }) + expect(wrapper.vm.basket[0]).to.equal('hello') + }) + + it('should update watchers correctly', () => { const TestComponent = { template: `