From fcad48abb7473d4306ddaf8808b314f8d25a87fd Mon Sep 17 00:00:00 2001 From: Jeremy Cassou Date: Fri, 25 Sep 2020 09:24:52 +0200 Subject: [PATCH] fix: support v-text on child functional components with shallowMount a child functional component must display content of v-text directive when it is mounted with shallowMount fix #1693 --- packages/create-instance/create-component-stubs.js | 3 +++ .../resources/components/component-with-functional-child.vue | 4 +++- test/resources/components/functional-component.vue | 4 +++- test/specs/shallow-mount.spec.js | 5 +++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/create-instance/create-component-stubs.js b/packages/create-instance/create-component-stubs.js index 2a6f81941..4fc6cd8d8 100644 --- a/packages/create-instance/create-component-stubs.js +++ b/packages/create-instance/create-component-stubs.js @@ -135,6 +135,9 @@ export function createStubFromComponent( tagName, { ref: componentOptions.functional ? context.data.ref : undefined, + domProps: componentOptions.functional + ? context.data.domProps + : undefined, attrs: componentOptions.functional ? { ...context.props, diff --git a/test/resources/components/component-with-functional-child.vue b/test/resources/components/component-with-functional-child.vue index 5d18f7272..16d638a02 100644 --- a/test/resources/components/component-with-functional-child.vue +++ b/test/resources/components/component-with-functional-child.vue @@ -1,6 +1,7 @@ @@ -15,7 +16,8 @@ export default { data() { return { a: 1, - b: 1 + b: 1, + something: 'value' } } } diff --git a/test/resources/components/functional-component.vue b/test/resources/components/functional-component.vue index 06a8d69bb..f9cc14c83 100644 --- a/test/resources/components/functional-component.vue +++ b/test/resources/components/functional-component.vue @@ -1,3 +1,5 @@ diff --git a/test/specs/shallow-mount.spec.js b/test/specs/shallow-mount.spec.js index 5251873f0..4d668a39d 100644 --- a/test/specs/shallow-mount.spec.js +++ b/test/specs/shallow-mount.spec.js @@ -41,6 +41,11 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => { ) }) + it('renders v-text content of functional child', () => { + const wrapper = shallowMount(ComponentWithFunctionalChild) + expect(wrapper.find('functional-component-stub').text()).toBe('value') + }) + it('returns new VueWrapper of Vue localVue if no options are passed', () => { const compiled = compileToFunctions('
') const wrapper = shallowMount(compiled)