Skip to content

Commit 236ab92

Browse files
xlfsummereddyerburgh
authored andcommitted
docs: add an example about using 'provide' option. (#928)
1 parent f592acc commit 236ab92

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/api/options.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,25 @@ expect(wrapper.vm.$parent.name).toBe('foo')
262262

263263
Pass properties for components to use in injection. See [provide/inject](https://vuejs.org/v2/api/#provide-inject).
264264

265+
Example:
266+
267+
```js
268+
const Component = {
269+
inject: ['foo'],
270+
template: '<div>{{this.foo()}}</div>'
271+
}
272+
273+
const wrapper = shallowMount(Component, {
274+
provide: {
275+
foo () {
276+
return 'fooValue'
277+
}
278+
}
279+
})
280+
281+
expect(wrapper.text()).toBe('fooValue')
282+
```
283+
265284
## sync
266285

267286
- type: `boolean`

0 commit comments

Comments
 (0)