Skip to content

Commit 0bad046

Browse files
authored
docs(ja): Create findComponent and findAllComponets (#1601)
* Create findComponent.md * Create findAllComponents.md * Update README.md * Update README.md * fix: fix typos
1 parent b8da036 commit 0bad046

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed

docs/ja/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
- [destroy](api/wrapper/destroy.md)
4444
- [find](api/wrapper/find.md)
4545
- [findAll](api/wrapper/findAll.md)
46+
- [findComponent](api/wrapper/findComponent.md)
47+
- [findAllComponents](api/wrapper/findAllComponents.md)
4648
- [html](api/wrapper/html.md)
4749
- [is](api/wrapper/is.md)
4850
- [isEmpty](api/wrapper/isEmpty.md)

docs/ja/api/wrapper/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ vue-test-utils はラッパベースの API です。
3131
!!!include(docs/ja/api/wrapper/exists.md)!!!
3232
!!!include(docs/ja/api/wrapper/find.md)!!!
3333
!!!include(docs/ja/api/wrapper/findAll.md)!!!
34+
!!!include(docs/ja/api/wrapper/findComponent.md)!!!
35+
!!!include(docs/ja/api/wrapper/findAllComponents.md)!!!
3436
!!!include(docs/ja/api/wrapper/html.md)!!!
3537
!!!include(docs/ja/api/wrapper/is.md)!!!
3638
!!!include(docs/ja/api/wrapper/isEmpty.md)!!!
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## findAllComponents
2+
3+
一致するすべての Vue コンポーネントの `WrapperArray` を返します。
4+
5+
- **引数:**
6+
7+
- `{Component|ref|name} selector`
8+
9+
- **戻り値:** `{WrapperArray}`
10+
11+
- **例:**
12+
13+
```js
14+
import { mount } from '@vue/test-utils'
15+
import Foo from './Foo.vue'
16+
import Bar from './Bar.vue'
17+
18+
const wrapper = mount(Foo)
19+
const bar = wrapper.findAllComponents(Bar).at(0)
20+
expect(bar.exists()).toBeTruthy()
21+
const bars = wrapper.findAllComponents(Bar)
22+
expect(bar).toHaveLength(1)
23+
```

docs/ja/api/wrapper/findComponent.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## findComponent
2+
3+
最初に一致した Vue コンポーネントの `Wrapper` を返します。
4+
5+
- **引数:**
6+
7+
- `{Component|ref|name} selector`
8+
9+
- **戻り値:** `{Wrapper}`
10+
11+
- **例:**
12+
13+
```js
14+
import { mount } from '@vue/test-utils'
15+
import Foo from './Foo.vue'
16+
import Bar from './Bar.vue'
17+
18+
const wrapper = mount(Foo)
19+
20+
const bar = wrapper.findComponent(Bar) // => コンポーネントインスタンスによってバーを検索します
21+
expect(bar.exists()).toBe(true)
22+
const barByName = wrapper.findComponent({ name: 'bar' }) // => `name` でバーを検索します
23+
expect(barByName.exists()).toBe(true)
24+
const barRef = wrapper.findComponent({ ref: 'bar' }) // => `ref` でバーを検索します
25+
expect(barRef.exists()).toBe(true)
26+
```

0 commit comments

Comments
 (0)