Skip to content

#132 additional work #198

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
Nov 23, 2017
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
2 changes: 1 addition & 1 deletion src/lib/create-instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default function createConstructor (
return h(
clonedComponent,
mountingOptions.context || component.FunctionalRenderContext,
(mountingOptions.context && mountingOptions.context.children) || createFunctionalSlots(mountingOptions.slots, h)
(mountingOptions.context && mountingOptions.context.children && mountingOptions.context.children.map(x => typeof x === 'function' ? x(h) : x)) || createFunctionalSlots(mountingOptions.slots, h)
)
}
}
Expand Down
21 changes: 18 additions & 3 deletions test/unit/specs/mount/options/context.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('context', () => {
expect(wrapper.element.textContent).to.equal(defaultValue)
})

it('mounts functional component with a defined context.children', () => {
it('mounts functional component with a defined context.children text', () => {
const Component = {
functional: true,
render: (h, { children }) => {
Expand All @@ -75,9 +75,24 @@ describe('context', () => {
}
const wrapper = mount(Component, {
context: {
children: ['hello']
children: ['render text']
}
})
expect(wrapper.text()).to.equal('hello')
expect(wrapper.text()).to.equal('render text')
})

it('mounts functional component with a defined context.children element', () => {
const Component = {
functional: true,
render: (h, { children }) => {
return h('div', children)
}
}
const wrapper = mount(Component, {
context: {
children: [h => h('div', 'render component')]
}
})
expect(wrapper.text()).to.equal('render component')
})
})