From 554891d8f5d7254c316a20f6a5080e86c8bf284b Mon Sep 17 00:00:00 2001
From: xlfsummer <20750969+xlfsummer@users.noreply.github.com>
Date: Thu, 16 Aug 2018 16:40:50 +0800
Subject: [PATCH 1/2] Add an example about using 'provide' option.
---
docs/api/options.md | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/docs/api/options.md b/docs/api/options.md
index 3ef0054ce..e57964bd7 100644
--- a/docs/api/options.md
+++ b/docs/api/options.md
@@ -262,6 +262,25 @@ expect(wrapper.vm.$parent.name).toBe('foo')
Pass properties for components to use in injection. See [provide/inject](https://vuejs.org/v2/api/#provide-inject).
+Example:
+
+```js
+const Component = {
+ inject: ["foo"],
+ template: "
{{this.foo()}}
"
+};
+
+const wrapper = shallowMount(Component, {
+ provide: {
+ foo() {
+ return "fooValue";
+ }
+ }
+});
+
+expect(wrapper.text()).toBe("fooValue");
+```
+
## sync
- type: `boolean`
From 45289edd92ea525bc9b4c29f9f47bd8a1b7b287a Mon Sep 17 00:00:00 2001
From: xlfsummer <20750969+xlfsummer@users.noreply.github.com>
Date: Thu, 16 Aug 2018 17:03:02 +0800
Subject: [PATCH 2/2] fix exmaple code style
---
docs/api/options.md | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/docs/api/options.md b/docs/api/options.md
index e57964bd7..9da120833 100644
--- a/docs/api/options.md
+++ b/docs/api/options.md
@@ -266,19 +266,19 @@ Example:
```js
const Component = {
- inject: ["foo"],
- template: "{{this.foo()}}
"
-};
+ inject: ['foo'],
+ template: '{{this.foo()}}
'
+}
const wrapper = shallowMount(Component, {
provide: {
- foo() {
- return "fooValue";
+ foo () {
+ return 'fooValue'
}
}
-});
+})
-expect(wrapper.text()).toBe("fooValue");
+expect(wrapper.text()).toBe('fooValue')
```
## sync