Skip to content

Commit 060e2e2

Browse files
38elementseddyerburgh
authored andcommitted
docs: update docs/ja (#281)
* docs: update docs/ja * Update README.md * Update trigger.md * Update trigger.md
1 parent ebccc8d commit 060e2e2

File tree

9 files changed

+75
-10
lines changed

9 files changed

+75
-10
lines changed

docs/ja/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
- [listeners](api/options.md#listeners)
2626
- [clone](api/options.md#clone)
2727
- [provide](api/options.md#provide)
28+
- [その他のオプション](api/options.md#その他のオプション)
2829
* [Wrapper](api/wrapper/README.md)
2930
* [attributes](api/wrapper/attributes.md)
3031
* [classes](api/wrapper/classes.md)

docs/ja/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- [listeners](api/options.md#listeners)
2424
- [clone](api/options.md#clone)
2525
- [provide](api/options.md#provide)
26+
- [その他のオプション](api/options.md#その他のオプション)
2627
* [Wrapper](api/wrapper/README.md)
2728
* [attributes](api/wrapper/attributes.md)
2829
* [classes](api/wrapper/classes.md)

docs/ja/api/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- [listeners](./options.md#listeners)
1414
- [clone](./options.md#clone)
1515
- [provide](./options.md#provide)
16+
- [その他のオプション](./options.md#その他のオプション)
1617
* [Wrapper](./wrapper/README.md)
1718
* [attributes](./wrapper/attributes.md)
1819
* [classes](./wrapper/classes.md)

docs/ja/api/options.md

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# マウンティングオプション
22

3-
`mount``shallow` に対するオプション。オプションオブジェクトには、`vue-test-utils` のマウントオプションと生の Vue オプションの両方を含めることができます。
4-
5-
新しくインスタンスが作成されると、Vue オプションがコンポーネントに渡されます。例: `store``propsData` など。完全なリストについては [Vue API ドキュメント](https://jp.vuejs.org/v2/api/)を参照してください。
3+
`mount``shallow` に対するオプション。オプションオブジェクトには、`vue-test-utils` のマウントオプションとその他のオプションを含めることができます。
64

75
## `vue-test-utils` の詳細なマウンティングオプション
86

@@ -58,6 +56,12 @@ const wrapper = shallow(Component, {
5856
expect(wrapper.find('div')).toBe(true)
5957
```
6058

59+
#### テキストを渡す
60+
61+
テキストを値として `slots` に渡すことはできますが、1つ制限事項があります。
62+
PhantomJS をサポートしません。
63+
[Puppeteer](https://github.com/karma-runner/karma-chrome-launcher#headless-chromium-with-puppeteer)を使用してください。
64+
6165
### `stubs`
6266

6367
- type: `{ [name: string]: Component | boolean } | Array<string>`
@@ -171,3 +175,33 @@ expect(wrapper.vm.$route).toBeInstanceOf(Object)
171175
- 型: `Object`
172176

173177
コンポーネントに指定したプロパティを注入します。[provide/inject](https://vuejs.org/v2/api/#provide-inject) を参照してください。
178+
179+
## その他のオプション
180+
181+
`mount` と `shallow` にマウンティングオプション以外のオプションが渡されると、コンポーネントのオプションは [extends](https://vuejs.org/v2/api/#extends) を使ってマウンティングオプション以外のオプションに上書きされます。
182+
183+
```js
184+
const Component = {
185+
template: '<div>{{ foo() }}{{ bar() }}{{ baz() }}</div>',
186+
methods: {
187+
foo () {
188+
return 'a'
189+
},
190+
bar () {
191+
return 'b'
192+
}
193+
}
194+
}
195+
const options = {
196+
methods: {
197+
bar () {
198+
return 'B'
199+
},
200+
baz () {
201+
return 'C'
202+
}
203+
}
204+
}
205+
const wrapper = mount(Component, options)
206+
expect(wrapper.text()).to.equal('aBC')
207+
```

docs/ja/api/shallow.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
- `{Object} options`
77
- `{boolean} attachToDocument`
88
- `{Object} context`
9+
- `{Array<Component|Object>|Component} children`
910
- `{Object} slots`
1011
- `{Array<Componet|Object>|Component|String} default`
1112
- `{Array<Componet|Object>|Component|String} named`
12-
- `{Object} intercept`
13+
- `{Object} mocks`
1314
- `{Object|Array<string>} stubs`
1415
- `{boolean} clone`
15-
- `{Object} children`
1616
- `{Vue} localVue`
1717

1818
- **戻り値:** `{Wrapper}`

docs/ja/api/wrapper-array/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- **プロパティ:**
66

7+
`wrappers` `array`: `WrapperArray` に含まれる `Wrappers`
78
`length` `number`: `WrapperArray` に含まれる `Wrappers` の数
89

910
- **メソッド:**

docs/ja/api/wrapper/emitted.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,15 @@ expect(wrapper.emitted('foo').length).toBe(2)
4444
// イベントのペイロードを検証します
4545
expect(wrapper.emitted('foo')[1]).toEqual([123])
4646
```
47+
48+
`.emitted()` メソッドは呼ばれる度、新しいオブジェクトではなく同じオブジェクトを返します。イベントが発生すると、そのオブジェクトは更新します。
49+
50+
```js
51+
const emitted = wrapper.emitted()
52+
53+
expect(emitted.foo.length).toBe(1)
54+
55+
// `wrapper` が foo イベントを emit する何らかの処理したとします。
56+
57+
expect(emitted.foo.length).toBe(2)
58+
```

docs/ja/api/wrapper/props.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@
99
- **例:**
1010

1111
```js
12-
import { mount } from 'vue-test-utils'
13-
import { expect } from 'chai'
1412
import Foo from './Foo.vue'
13+
import Bar from './Bar.vue'
1514

16-
const wrapper = mount(Foo, {
17-
propsData: 'baz'
15+
const wrapper = mount(Component, {
16+
context: {
17+
props: { show: true },
18+
children: [Foo, Bar]
19+
}
1820
})
19-
expect(wrapper.props().bar).toBe('baz')
21+
22+
expect(wrapper.is(Component)).toBe(true)
2023
```

docs/ja/api/wrapper/trigger.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,15 @@ wrapper.trigger('click', {
3636

3737
expect(clickHandler.called).toBe(true)
3838
```
39+
40+
- **イベントターゲットの設定:**
41+
42+
`trigger` は `Event` オブジェクトを生成して、Wrapper.element にイベントを送ります。
43+
`Event` オブジェクトの `target` 値を編集できません。つまり、 `target` を オプションオブジェクトにセットすることはできません。
44+
`target` の属性を追加するには、 `trigger` を実行する前に Wrapper.element の属性にその値をセットする必要があります。
45+
46+
```js
47+
const input = wrapper.find('input')
48+
input.element.value = 100
49+
input.trigger('click')
50+
```

0 commit comments

Comments
 (0)