From 2a01b81aa764b9b56448a737a1bc50a3b5b02986 Mon Sep 17 00:00:00 2001 From: Aron Griffis Date: Thu, 12 Jul 2018 09:28:36 -0400 Subject: [PATCH] test: demonstrate setProps bug through computed and created (#738) --- .../component-with-computed-created.vue | 15 +++++++++++++++ test/specs/wrapper/setProps.spec.js | 9 +++++++++ 2 files changed, 24 insertions(+) create mode 100644 test/resources/components/component-with-computed-created.vue diff --git a/test/resources/components/component-with-computed-created.vue b/test/resources/components/component-with-computed-created.vue new file mode 100644 index 000000000..ef66af517 --- /dev/null +++ b/test/resources/components/component-with-computed-created.vue @@ -0,0 +1,15 @@ + + diff --git a/test/specs/wrapper/setProps.spec.js b/test/specs/wrapper/setProps.spec.js index 228cc7027..f86dc64d8 100644 --- a/test/specs/wrapper/setProps.spec.js +++ b/test/specs/wrapper/setProps.spec.js @@ -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 => { @@ -90,6 +91,14 @@ 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'