Skip to content

Commit 7e23e09

Browse files
authored
fix: force update in setProps (#752)
1 parent 3494fc0 commit 7e23e09

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Diff for: packages/test-utils/src/wrapper.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,8 @@ export default class Wrapper implements BaseWrapper {
664664
this.vm.$options.propsData[key] = data[key]
665665
}
666666
})
667-
667+
// $FlowIgnore : Problem with possibly null this.vm
668+
this.vm.$forceUpdate()
668669
// $FlowIgnore : Problem with possibly null this.vm
669670
orderWatchers(this.vm || this.vnode.context.$root)
670671
Vue.config.silent = originalConfig

Diff for: test/specs/wrapper/setProps.spec.js

+14
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ describeWithShallowAndMount('setProps', mountingMethod => {
2424
expect(wrapper.find('.prop-2').element.textContent).to.equal(prop2)
2525
})
2626

27+
it('sets props and updates when called with same object', () => {
28+
const TestComponent = {
29+
template: '<div v-if="obj && obj.shouldRender()" />',
30+
props: ['obj']
31+
}
32+
const obj = {
33+
shouldRender: () => false
34+
}
35+
const wrapper = mountingMethod(TestComponent)
36+
obj.shouldRender = () => true
37+
wrapper.setProps({ obj })
38+
expect(wrapper.is('div')).to.equal(true)
39+
})
40+
2741
it('throws error if component does not include props key', () => {
2842
const TestComponent = {
2943
template: '<div></div>'

0 commit comments

Comments
 (0)