Skip to content

Commit d86684d

Browse files
committed
docs: add an example for slots components with props
1 parent 0a72913 commit d86684d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

docs/api/options.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,37 @@ const wrapper = shallowMount(Component, {
7474
expect(wrapper.find('div')).toBe(true)
7575
```
7676

77+
You can also provide slots components with props.
78+
Example:
79+
80+
```js
81+
const wrapper = mount(Component, {
82+
slots: {
83+
default: `<child foo="bar"/><child :foo="val"/>`
84+
},
85+
mocks: {
86+
val: 'qux'
87+
},
88+
stubs: {
89+
child: {
90+
props: {
91+
foo: {
92+
type: String,
93+
required: true
94+
}
95+
},
96+
render(h) {
97+
return h('p', this.foo)
98+
}
99+
}
100+
}
101+
})
102+
103+
expect(wrapper.findAll('p').length).toBe(2)
104+
expect(wrapper.text()).toMatch(/bar/)
105+
expect(wrapper.text()).toMatch(/qux/)
106+
```
107+
77108
## scopedSlots
78109

79110
- type: `{ [name: string]: string|Function }`

0 commit comments

Comments
 (0)