Skip to content

fix: support v-text on child functional components with shallowMount (fix #1693) #1697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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