Skip to content

Commit

Permalink
test: demonstrate setProps bug through computed and created (vuejs#738)
Browse files Browse the repository at this point in the history
  • Loading branch information
agriffis committed Jul 12, 2018
1 parent 4f9af82 commit b6e1d9c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/resources/components/component-with-computed-created.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<script>
export default {
name: 'my-component',
props: ['prop1'],
computed: {
prop2() {
return this.prop1
},
},
created() {
this.prop2
},
}
</script>

7 changes: 7 additions & 0 deletions test/specs/wrapper/setProps.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { compileToFunctions } from 'vue-template-compiler'
import ComponentWithProps from '~resources/components/component-with-props.vue'
import ComponentWithWatch from '~resources/components/component-with-watch.vue'
import ComponentWithComputedCreated from '~resources/components/component-with-computed-created.vue'
import { describeWithShallowAndMount, vueVersion } from '~resources/utils'

describeWithShallowAndMount('setProps', mountingMethod => {
Expand Down Expand Up @@ -90,6 +91,12 @@ describeWithShallowAndMount('setProps', mountingMethod => {
expect(wrapper.find('.prop-2').element.textContent).to.equal(prop2)
})

it('sets component prop referenced through computed and created', () => {
const wrapper = mountingMethod(ComponentWithComputedCreated, {propsData: {prop1: 1}})
wrapper.setProps({prop1: 2})
expect(wrapper.vm.prop1).to.equal(2)
})

it('runs watch function when prop is updated', () => {
const wrapper = mountingMethod(ComponentWithWatch)
const prop1 = 'testest'
Expand Down

0 comments on commit b6e1d9c

Please sign in to comment.