Skip to content

Commit

Permalink
docs: improve docs/api/options.md (#735)
Browse files Browse the repository at this point in the history
  • Loading branch information
38elements authored and eddyerburgh committed Jun 18, 2018
1 parent daa56aa commit 97b505d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
2 changes: 2 additions & 0 deletions docs/api/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ shallowMount(Component, {
// stub with a specific implementation
'registered-component': Foo,
// create default stub
// another-component is the default stub component name
// the default stub is <${default stub component name}-stub>
'another-component': true
}
})
Expand Down
26 changes: 15 additions & 11 deletions test/specs/mounting-options/stubs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,23 @@ describeWithMountingMethods('options.stub', mountingMethod => {
expect(HTML).not.to.contain('<span>')
})

it('stubs components with dummy when passed a boolean', () => {
const ComponentWithGlobalComponent = {
render: h => h('div', [h('registered-component')])
}
const wrapper = mountingMethod(ComponentWithGlobalComponent, {
stubs: {
'registered-component': true
itDoNotRunIf(
mountingMethod.name === 'renderToString',
'stubs components with dummy which has name when passed a boolean', () => {
const ComponentWithGlobalComponent = {
render: h => h('div', [h('registered-component')])
}
const wrapper = mountingMethod(ComponentWithGlobalComponent, {
stubs: {
'registered-component': true
}
})
const HTML =
mountingMethod.name === 'renderToString' ? wrapper : wrapper.html()
expect(HTML).to.contain('<registered-component-stub>')
expect(wrapper.find({ name: 'registered-component' }).html())
.to.equal('<registered-component-stub></registered-component-stub>')
})
const HTML =
mountingMethod.name === 'renderToString' ? wrapper : wrapper.html()
expect(HTML).to.contain('<registered-component-stub>')
})

it('stubs components with dummy when passed as an array', () => {
const ComponentWithGlobalComponent = {
Expand Down

0 comments on commit 97b505d

Please sign in to comment.