Skip to content

Commit

Permalink
fix: run watchers before updating component
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyerburgh committed Jan 9, 2018
1 parent 30659a5 commit c095221
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 36 deletions.
6 changes: 3 additions & 3 deletions src/wrappers/vue-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ function update () {
if (this.$_mountingOptionsSlots) {
addSlots(this, this.$_mountingOptionsSlots)
}
const vnodes = this._render()
this._update(vnodes)
this.$children.forEach(child => update.call(child))
this._watchers.forEach(watcher => {
watcher.run()
})
const vnodes = this._render()
this._update(vnodes)
this.$children.forEach(child => update.call(child))
}

export default class VueWrapper extends Wrapper implements BaseWrapper {
Expand Down
33 changes: 0 additions & 33 deletions test/unit/specs/TransitionGroupStub.spec.js

This file was deleted.

49 changes: 49 additions & 0 deletions test/unit/specs/components/TransitionGroupStub.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import ComponentWithTransitionGroup from '~resources/components/component-with-transition-group.vue'
import TransitionGroupStub from '~src/components/TransitionGroupStub'
import { mount } from '~vue-test-utils'

describe('TransitionGroupStub', () => {
it('update synchronously when used as stubs for Transition', () => {
const wrapper = mount(ComponentWithTransitionGroup, {
stubs: {
'transition-group': TransitionGroupStub
}
})
expect(wrapper.text()).contains('a')
wrapper.setData({ a: 'b' })
expect(wrapper.text()).contains('b')
})

it('updates watchers', () => {
const TestComponent = {
data: () => ({
someWatchedData: null,
someData: null
}),
watch: {
someWatchedData (newData) {
console.log('asd')
this.someData = newData
}
},
template: `
<transition-group
mode="out-in"
class="body"
tag="div"
>
{{someData}}
</transition-group>
`
}
const wrapper = mount(TestComponent, {
stubs: {
'transition-group': TransitionGroupStub
}
})
wrapper.setData({
someWatchedData: 'some data'
})
expect(wrapper.html()).contains('some data')
})
})
File renamed without changes.

0 comments on commit c095221

Please sign in to comment.