Skip to content

Commit

Permalink
fix: force update in setProps (#752)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyerburgh committed Jun 24, 2018
1 parent 3494fc0 commit 7e23e09
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/test-utils/src/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,8 @@ export default class Wrapper implements BaseWrapper {
this.vm.$options.propsData[key] = data[key]
}
})

// $FlowIgnore : Problem with possibly null this.vm
this.vm.$forceUpdate()
// $FlowIgnore : Problem with possibly null this.vm
orderWatchers(this.vm || this.vnode.context.$root)
Vue.config.silent = originalConfig
Expand Down
14 changes: 14 additions & 0 deletions test/specs/wrapper/setProps.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ describeWithShallowAndMount('setProps', mountingMethod => {
expect(wrapper.find('.prop-2').element.textContent).to.equal(prop2)
})

it('sets props and updates when called with same object', () => {
const TestComponent = {
template: '<div v-if="obj && obj.shouldRender()" />',
props: ['obj']
}
const obj = {
shouldRender: () => false
}
const wrapper = mountingMethod(TestComponent)
obj.shouldRender = () => true
wrapper.setProps({ obj })
expect(wrapper.is('div')).to.equal(true)
})

it('throws error if component does not include props key', () => {
const TestComponent = {
template: '<div></div>'
Expand Down

0 comments on commit 7e23e09

Please sign in to comment.