Skip to content

Commit

Permalink
fix: support v-text on child functional components with shallowMount (#…
Browse files Browse the repository at this point in the history
…1697)

a child functional component must display content of v-text directive when it is mounted with
shallowMount

fix #1693

Co-authored-by: Jeremy Cassou <jeremy.cassou@agilea-group.com>
  • Loading branch information
jeremy-cassou and Jeremy Cassou committed Sep 25, 2020
1 parent c4c940d commit bb949a1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/create-instance/create-component-stubs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<functional-component
:class="{ bar: a + b === 2, foo: a === 1, qux: a === 2 }"
v-text="something"
/>
</template>

Expand All @@ -15,7 +16,8 @@ export default {
data() {
return {
a: 1,
b: 1
b: 1,
something: 'value'
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion test/resources/components/functional-component.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<template functional>
<div />
<div>
<slot />
</div>
</template>
5 changes: 5 additions & 0 deletions test/specs/shallow-mount.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<div><input /></div>')
const wrapper = shallowMount(compiled)
Expand Down

0 comments on commit bb949a1

Please sign in to comment.