Skip to content

Commit c095221

Browse files
committed
fix: run watchers before updating component
1 parent 30659a5 commit c095221

File tree

4 files changed

+52
-36
lines changed

4 files changed

+52
-36
lines changed

src/wrappers/vue-wrapper.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ function update () {
1212
if (this.$_mountingOptionsSlots) {
1313
addSlots(this, this.$_mountingOptionsSlots)
1414
}
15-
const vnodes = this._render()
16-
this._update(vnodes)
17-
this.$children.forEach(child => update.call(child))
1815
this._watchers.forEach(watcher => {
1916
watcher.run()
2017
})
18+
const vnodes = this._render()
19+
this._update(vnodes)
20+
this.$children.forEach(child => update.call(child))
2121
}
2222

2323
export default class VueWrapper extends Wrapper implements BaseWrapper {

test/unit/specs/TransitionGroupStub.spec.js

-33
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import ComponentWithTransitionGroup from '~resources/components/component-with-transition-group.vue'
2+
import TransitionGroupStub from '~src/components/TransitionGroupStub'
3+
import { mount } from '~vue-test-utils'
4+
5+
describe('TransitionGroupStub', () => {
6+
it('update synchronously when used as stubs for Transition', () => {
7+
const wrapper = mount(ComponentWithTransitionGroup, {
8+
stubs: {
9+
'transition-group': TransitionGroupStub
10+
}
11+
})
12+
expect(wrapper.text()).contains('a')
13+
wrapper.setData({ a: 'b' })
14+
expect(wrapper.text()).contains('b')
15+
})
16+
17+
it('updates watchers', () => {
18+
const TestComponent = {
19+
data: () => ({
20+
someWatchedData: null,
21+
someData: null
22+
}),
23+
watch: {
24+
someWatchedData (newData) {
25+
console.log('asd')
26+
this.someData = newData
27+
}
28+
},
29+
template: `
30+
<transition-group
31+
mode="out-in"
32+
class="body"
33+
tag="div"
34+
>
35+
{{someData}}
36+
</transition-group>
37+
`
38+
}
39+
const wrapper = mount(TestComponent, {
40+
stubs: {
41+
'transition-group': TransitionGroupStub
42+
}
43+
})
44+
wrapper.setData({
45+
someWatchedData: 'some data'
46+
})
47+
expect(wrapper.html()).contains('some data')
48+
})
49+
})

0 commit comments

Comments
 (0)