diff --git a/packages/shared/stub-components.js b/packages/shared/stub-components.js index cd27a4f4a..3cc1ba207 100644 --- a/packages/shared/stub-components.js +++ b/packages/shared/stub-components.js @@ -99,10 +99,10 @@ function createBlankStub ( return { ...getCoreProperties(componentOptions), - render (h) { + render (h, context) { return h( tagName, - !componentOptions.functional && this.$slots.default + context ? context.children : this.$slots.default ) } } diff --git a/test/specs/shallow-mount.spec.js b/test/specs/shallow-mount.spec.js index 21481c993..3b486bc27 100644 --- a/test/specs/shallow-mount.spec.js +++ b/test/specs/shallow-mount.spec.js @@ -63,6 +63,44 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => { expect(console.info.callCount).to.equal(4) }) + it('renders children', () => { + const localVue = createLocalVue() + localVue.component('child', { + template: '
' + }) + const TestComponent = { + template: `{{'Hello'}}` + } + const wrapper = shallowMount(TestComponent, { + localVue + }) + expect(wrapper.html()).to.equal('Hello') + }) + + it('renders no children if none supplied', () => { + const TestComponent = { + template: '', + components: { Child: { }} + } + const wrapper = shallowMount(TestComponent) + expect(wrapper.html()).to.equal('') + }) + + it('renders children for functional components', () => { + const localVue = createLocalVue() + localVue.component('child', { + template: '
', + functional: true + }) + const TestComponent = { + template: `{{'Hello'}}` + } + const wrapper = shallowMount(TestComponent, { + localVue + }) + expect(wrapper.html()).to.equal('Hello') + }) + it('stubs globally registered components', () => { Vue.component('registered-component', ComponentWithLifecycleHooks) const Component = {