Skip to content

Commit 2a01b81

Browse files
committed
test: demonstrate setProps bug through computed and created (#738)
1 parent 22b909e commit 2a01b81

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<script>
2+
export default {
3+
name: 'my-component',
4+
props: ['prop1'],
5+
computed: {
6+
prop2 () {
7+
return this.prop1
8+
}
9+
},
10+
created () {
11+
this.prop2
12+
}
13+
}
14+
</script>
15+

test/specs/wrapper/setProps.spec.js

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { compileToFunctions } from 'vue-template-compiler'
22
import ComponentWithProps from '~resources/components/component-with-props.vue'
33
import ComponentWithWatch from '~resources/components/component-with-watch.vue'
4+
import ComponentWithComputedCreated from '~resources/components/component-with-computed-created.vue'
45
import { describeWithShallowAndMount, vueVersion } from '~resources/utils'
56

67
describeWithShallowAndMount('setProps', mountingMethod => {
@@ -90,6 +91,14 @@ describeWithShallowAndMount('setProps', mountingMethod => {
9091
expect(wrapper.find('.prop-2').element.textContent).to.equal(prop2)
9192
})
9293

94+
it('sets component prop referenced through computed and created', () => {
95+
const wrapper = mountingMethod(ComponentWithComputedCreated, {
96+
propsData: { prop1: 1 }
97+
})
98+
wrapper.setProps({ prop1: 2 })
99+
expect(wrapper.vm.prop1).to.equal(2)
100+
})
101+
93102
it('runs watch function when prop is updated', () => {
94103
const wrapper = mountingMethod(ComponentWithWatch)
95104
const prop1 = 'testest'

0 commit comments

Comments
 (0)