Skip to content

Commit 2f4c073

Browse files
kazuponeddyerburgh
authored andcommitted
update docs/ja (#978)
1 parent c04d3bf commit 2f4c073

File tree

4 files changed

+65
-3
lines changed

4 files changed

+65
-3
lines changed

Diff for: docs/ja/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828
- [localVue](api/options.md#localvue)
2929
- [attachToDocument](api/options.md#attachtodocument)
3030
- [attrs](api/options.md#attrs)
31+
- [propsData](api/options.md#propsdata)
3132
- [listeners](api/options.md#listeners)
32-
- [parentComponent](api/options.md#parentComponent)
33+
- [parentComponent](api/options.md#parentcomponent)
3334
- [provide](api/options.md#provide)
3435
- [sync](api/options.md#sync)
3536
- [その他のオプション](api/options.md#その他のオプション)

Diff for: docs/ja/api/options.md

+48-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
- [`localVue`](#localvue)
1111
- [`attachToDocument`](#attachtodocument)
1212
- [`attrs`](#attrs)
13+
- [`propsData`](#propsdata)
1314
- [`listeners`](#listeners)
14-
- [`parentComponent`](#parentComponent)
15+
- [`parentComponent`](#parentcomponent)
1516
- [`provide`](#provide)
1617
- [`sync`](#sync)
1718

@@ -202,6 +203,33 @@ expect(wrapper.vm.$route).toBeInstanceOf(Object)
202203

203204
コンポーネントインスタンスの `$attrs` オブジェクトを設定します。
204205

206+
## propsData
207+
208+
- 型: `Object`
209+
210+
コンポーネントがマウントされる時、コンポーネントインスタンスの props をセットします。
211+
212+
例:
213+
214+
```js
215+
const Component = {
216+
template: '<div>{{ msg }}</div>',
217+
props: ['msg']
218+
}
219+
const wrapper = mount(Component, {
220+
propsData: {
221+
msg: 'aBC'
222+
}
223+
})
224+
expect(wrapper.text()).toBe('aBC')
225+
```
226+
227+
::: 注意
228+
`propsData` は Vue Test Utils のマウンティングオプションではなく [Vue API](https://vuejs.org/v2/api/#propsData) です。
229+
この `propsData`[`extends`](https://vuejs.org/v2/api/#extends) を内部で利用しています。
230+
詳しくは[その他のオプション](#その他のオプション)を参照してください。
231+
:::
232+
205233
## listeners
206234

207235
- 型: `Object`
@@ -231,6 +259,25 @@ expect(wrapper.vm.$parent.$options.name).toBe('foo')
231259

232260
コンポーネントに指定したプロパティを注入します。[provide/inject](https://vuejs.org/v2/api/#provide-inject) を参照してください。
233261

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

236283
- 型: `boolean`

Diff for: docs/ja/api/shallowMount.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ describe('Foo', () => {
9090
foo: '<div />'
9191
}
9292
})
93-
expect(wrapper.find('div')).toBe(true)
93+
expect(wrapper.contains('div')).toBe(true)
9494
})
9595
})
9696
```

Diff for: docs/ja/guides/common-tips.md

+14
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,20 @@ mount(Component, {
131131
})
132132
```
133133

134+
### スタブコンポーネント
135+
136+
`stubs` オプションを使用して、グローバルまたはローカルに登録されたコンポーネントを上書きできます:
137+
138+
```js
139+
import { mount } from '@vue/test-utils'
140+
141+
mount(Component, {
142+
// globally-registered-component を空のスタブとして
143+
// 解決します
144+
stubs: ['globally-registered-component']
145+
})
146+
```
147+
134148
### ルーティングの扱い
135149

136150
定義によるルーティングは、アプリケーションの全体的な構造と関連し、複数のコンポーネントが関係するため、統合テストまたはエンドツーエンドテストによってよくテストされます。

0 commit comments

Comments
 (0)