From 6b7767709166ee07682b5c32715b4689cbaad3f3 Mon Sep 17 00:00:00 2001 From: eddyerburgh Date: Thu, 14 Jun 2018 17:21:54 +0100 Subject: [PATCH 1/2] feat: render default slot in stubs --- packages/shared/stub-components.js | 4 ++- test/specs/mounting-options/stubs.spec.js | 36 ++++++++++++----------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/packages/shared/stub-components.js b/packages/shared/stub-components.js index 697e0eaf2..b84d91ec4 100644 --- a/packages/shared/stub-components.js +++ b/packages/shared/stub-components.js @@ -65,7 +65,9 @@ function createBlankStub (originalComponent: Component) { return { ...getCoreProperties(originalComponent), render (h) { - return h(`${originalComponent.name}-stub`) + return h(`${originalComponent.name}-stub`, + !originalComponent.functional && this.$slots.default + ) } } } diff --git a/test/specs/mounting-options/stubs.spec.js b/test/specs/mounting-options/stubs.spec.js index a81b48baf..fe44c94c3 100644 --- a/test/specs/mounting-options/stubs.spec.js +++ b/test/specs/mounting-options/stubs.spec.js @@ -96,6 +96,25 @@ describeWithMountingMethods('options.stub', (mountingMethod) => { expect(mountedWrapper.findAll(Component).length).to.equal(1) }) + it('renders slot content in stubs', () => { + const TestComponent = { + template: ` +
+ + + +
+ ` + } + const wrapper = mountingMethod(TestComponent, { + stubs: ['child-component', 'stub-with-child'] + }) + const HTML = mountingMethod.name === 'renderToString' + ? wrapper + : wrapper.html() + expect(HTML).to.contain('') + }) + it('stubs components on component if they do not already exist', () => { const ComponentWithGlobalComponent = { render: h => h('registered-component') @@ -246,23 +265,6 @@ describeWithMountingMethods('options.stub', (mountingMethod) => { expect(HTML).to.contain('') }) - itDoNotRunIf( - mountingMethod.name === 'shallowMount' || - mountingMethod.name === 'renderToString', - 'stubs on child components', () => { - const TestComponent = { - template: '' - } - - const wrapper = mountingMethod({ - components: { 'test-component': TestComponent }, - template: '' - }, { - stubs: ['transition'] - }) - expect(wrapper.find('span').exists()).to.equal(false) - }) - it('converts config to array if stubs is an array', () => { const localVue = createLocalVue() config.stubs['time-component'] = '

' From 3cecf8472da1798576c172d40e3a5435bea60c48 Mon Sep 17 00:00:00 2001 From: Edd Yerburgh Date: Thu, 21 Jun 2018 19:21:35 +0100 Subject: [PATCH 2/2] Update stubs.spec.js --- test/specs/mounting-options/stubs.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/specs/mounting-options/stubs.spec.js b/test/specs/mounting-options/stubs.spec.js index 2bde9ee83..677091295 100644 --- a/test/specs/mounting-options/stubs.spec.js +++ b/test/specs/mounting-options/stubs.spec.js @@ -333,7 +333,6 @@ describeWithMountingMethods('options.stub', mountingMethod => { expect(HTML).to.contain('') }) - itDoNotRunIf( mountingMethod.name === 'shallowMount' || mountingMethod.name === 'renderToString',