Skip to content

Commit b3f89c5

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

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-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+

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

+7
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,12 @@ 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, {propsData: {prop1: 1}})
96+
wrapper.setProps({prop1: 2})
97+
expect(wrapper.vm.prop1).to.equal(2)
98+
})
99+
93100
it('runs watch function when prop is updated', () => {
94101
const wrapper = mountingMethod(ComponentWithWatch)
95102
const prop1 = 'testest'

0 commit comments

Comments
 (0)