Skip to content
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
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
  • Loading branch information
Jeremy Cassou committed Sep 25, 2020
commit fcad48abb7473d4306ddaf8808b314f8d25a87fd
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