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
7 changes: 1 addition & 6 deletions packages/create-instance/create-component-stubs.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,8 @@ export function createStubsFromStubsObject (
if (componentNeedsCompiling(stub)) {
compileTemplate(stub)
}
const name = originalComponents[stubName] &&
originalComponents[stubName].name

acc[stubName] = {
name,
...stub
}
acc[stubName] = stub

return acc
}, {})
Expand Down
40 changes: 32 additions & 8 deletions test/specs/mounting-options/stubs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ describeWithMountingMethods('options.stub', mountingMethod => {
mountingMethod.name === 'renderToString',
'replaces component with a component',
() => {
const mounted = sinon.stub()
const Stub = {
template: '<div />',
mounted
}
const wrapper = mountingMethod(ComponentWithChild, {
stubs: {
ChildComponent: {
render: h => h('time'),
mounted () {
console.info('stubbed')
}
}
ChildComponent: Stub
}
})
expect(wrapper.findAll(Component).length).to.equal(1)
expect(info.calledWith('stubbed')).to.equal(true)
expect(wrapper.findAll(Stub).length).to.equal(1)
expect(mounted).calledOnce
}
)

Expand Down Expand Up @@ -567,4 +567,28 @@ describeWithMountingMethods('options.stub', mountingMethod => {
)
expect(HTML).to.contain('h1')
})

itDoNotRunIf(
mountingMethod.name === 'renderToString',
'uses original component stub', () => {
const Stub = {
template: '<div />'
}
const ToStub = {
template: '<div />'
}
const TestComponent = {
template: '<div><to-stub /></div>',
components: {
ToStub
}
}
const wrapper = mountingMethod(TestComponent, {
stubs: {
ToStub: Stub
}
})
expect(wrapper.find(ToStub).exists()).to.be.false
expect(wrapper.find(Stub).exists()).to.be.true
})
})