Skip to content

Commit b6bd76d

Browse files
38elementskuitos
authored andcommitted
docs: update docs/ja (vuejs#872)
1 parent 6d036f9 commit b6bd76d

File tree

7 files changed

+82
-14
lines changed

7 files changed

+82
-14
lines changed

Diff for: docs/ja/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
- [attachToDocument](api/options.md#attachtodocument)
2929
- [attrs](api/options.md#attrs)
3030
- [listeners](api/options.md#listeners)
31+
- [parentComponent](api/options.md#parentComponent)
3132
- [provide](api/options.md#provide)
3233
- [sync](api/options.md#sync)
3334
- [その他のオプション](api/options.md#その他のオプション)
@@ -77,5 +78,6 @@
7778
* [TransitionGroupStub](api/components/TransitionGroupStub.md)
7879
* [RouterLinkStub](api/components/RouterLinkStub.md)
7980
* [セレクタ](api/selectors.md)
81+
* [createWrapper](api/createWrapper.md)
8082
* [createLocalVue](api/createLocalVue.md)
8183
* [config](api/config.md)

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
!!!include(docs/ja/api/renderToString.md)!!!
77
!!!include(docs/ja/api/selectors.md)!!!
88
!!!include(docs/ja/api/createLocalVue.md)!!!
9-
!!!include(docs/ja/api/config.md)!!!
9+
!!!include(docs/ja/api/createWrapper.md)!!!
10+
!!!include(docs/ja/api/config.md)!!!

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

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## createWrapper(node [, options])
2+
3+
- **引数:**
4+
5+
- `{vm|HTMLElement} node`
6+
- `{Object} options`
7+
- `{Boolean} sync`
8+
- `{Boolean} attachedToDocument`
9+
10+
- **戻り値:**
11+
- `{Wrapper}`
12+
13+
- **使い方:**
14+
15+
`createWrapper` は Vue インスタンスまたは HTML 要素に対する `Wrapper` を生成します。
16+
17+
```js
18+
import { createWrapper } from '@vue/test-utils'
19+
import Foo from './Foo.vue'
20+
21+
const Constructor = Vue.extend(Foo)
22+
const vm = new Constructor().$mount()
23+
const wrapper = createWrapper(vm)
24+
expect(wrapper.vm.foo).toBe(true)
25+
```

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

+30-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- [`attachToDocument`](#attachtodocument)
1212
- [`attrs`](#attrs)
1313
- [`listeners`](#listeners)
14+
- [`parentComponent`](#parentComponent)
1415
- [`provide`](#provide)
1516
- [`sync`](#sync)
1617

@@ -42,15 +43,23 @@ expect(wrapper.is(Component)).toBe(true)
4243

4344
```js
4445
import Foo from './Foo.vue'
45-
import Bar from './Bar.vue'
46+
47+
const bazComponent = {
48+
name: 'baz-component',
49+
template: '<p>baz</p>'
50+
}
4651

4752
const wrapper = shallowMount(Component, {
4853
slots: {
49-
default: [Foo, Bar],
50-
fooBar: Foo, // Will match <slot name="FooBar" />,
51-
foo: '<div />'
54+
default: [Foo, '<my-component />', 'text'],
55+
fooBar: Foo, // `<slot name="FooBar" />` にマッチします。
56+
foo: '<div />',
57+
bar: 'bar',
58+
baz: bazComponent,
59+
qux: '<my-component />'
5260
}
5361
})
62+
5463
expect(wrapper.find('div')).toBe(true)
5564
```
5665

@@ -177,6 +186,23 @@ expect(wrapper.vm.$route).toBeInstanceOf(Object)
177186

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

189+
## parentComponent
190+
191+
- 型: `Object`
192+
193+
マウントされるコンポーネントの親コンポーネントとして使用されるコンポーネントです。
194+
195+
例:
196+
197+
```js
198+
import Foo from './Foo.vue'
199+
200+
const wrapper = shallowMount(Component, {
201+
parentComponent: Foo
202+
})
203+
expect(wrapper.vm.$parent.name).toBe('foo')
204+
```
205+
180206
## provide
181207

182208
- 型: `Object`

Diff for: docs/ja/api/wrapper/setChecked.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import { mount } from '@vue/test-utils'
1212
import Foo from './Foo.vue'
1313

1414
const wrapper = mount(Foo)
15-
const option = wrapper.find('input[type="radio"]')
16-
option.setChecked()
15+
const radioInput = wrapper.find('input[type="radio"]')
16+
radioInput.setChecked()
1717
```
1818

1919
- **注:**

Diff for: docs/ja/api/wrapper/setData.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
`Wrapper` `vm` データを設定します。
44

5+
setData は再帰的に Vue.set を実行することで動作します。
6+
57
**Wrapper には Vue インスタンスを含む必要があることに注意してください**
68

79
- **引数:**

Diff for: docs/ja/api/wrapper/setValue.md

+19-7
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,27 @@ import { mount } from '@vue/test-utils'
1212
import Foo from './Foo.vue'
1313

1414
const wrapper = mount(Foo)
15-
const input = wrapper.find('input[type="text"]')
16-
input.setValue('some value')
15+
16+
const textInput = wrapper.find('input[type="text"]')
17+
textInput.setValue('some value')
18+
19+
const select = wrapper.find('select')
20+
select.setValue('option value')
1721
```
1822

23+
1924
- **注:**
2025

21-
`textInput.setValue(value)` は以下のコードのエイリアスです。
26+
- `textInput.setValue(value)` は以下のコードのエイリアスです。
2227

23-
```js
24-
textInput.element.value = value
25-
textInput.trigger('input')
26-
```
28+
```js
29+
textInput.element.value = value
30+
textInput.trigger('input')
31+
```
32+
33+
- `select.setValue(value)` は以下のコードのエイリアスです。
34+
35+
```js
36+
select.element.value = value
37+
select.trigger('change')
38+
```

0 commit comments

Comments
 (0)