Skip to content

Commit b714ce3

Browse files
committed
fix: update child Vue instances
fixes #66
1 parent 852d2ab commit b714ce3

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/wrappers/vue-wrapper.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { logEvents } from '../lib/log-events'
55

66
function update () {
77
this._update(this._render())
8+
this.$children.forEach(child => update.call(child))
89
}
910

1011
export default class VueWrapper extends Wrapper implements BaseWrapper {

test/unit/specs/mount/Wrapper/update.spec.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,33 @@ describe('update', () => {
1111
expect(wrapper.findAll('.child.ready').length).to.equal(1)
1212
})
1313

14+
it('updates slot components', () => {
15+
const SlotComponent = compileToFunctions('<div><slot></slot></div>')
16+
const Parent = {
17+
template: `
18+
<SlotComponent>
19+
<div :class="[{ 'is-on': on }, 'inner']"></div>
20+
</SlotComponent>
21+
`,
22+
props: {
23+
on: {
24+
default: false,
25+
type: Boolean
26+
}
27+
},
28+
components: {
29+
SlotComponent
30+
}
31+
}
32+
const parentWrapper = mount(Parent)
33+
const innerEl = parentWrapper.find('.inner')
34+
expect(innerEl.hasClass('is-on')).to.equal(false)
35+
parentWrapper.setProps({
36+
on: true
37+
})
38+
expect(innerEl.hasClass('is-on')).to.equal(true)
39+
})
40+
1441
it('causes vm to re render, and retain slots', () => {
1542
const compiled = compileToFunctions('<div><slot></slot></div>')
1643
const wrapper = mount(compiled, { slots: { default: [compileToFunctions('<div class="test-div" />')] }})

0 commit comments

Comments
 (0)