Skip to content

docs: update docs/ja #872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/ja/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- [attachToDocument](api/options.md#attachtodocument)
- [attrs](api/options.md#attrs)
- [listeners](api/options.md#listeners)
- [parentComponent](api/options.md#parentComponent)
- [provide](api/options.md#provide)
- [sync](api/options.md#sync)
- [その他のオプション](api/options.md#その他のオプション)
Expand Down Expand Up @@ -77,5 +78,6 @@
* [TransitionGroupStub](api/components/TransitionGroupStub.md)
* [RouterLinkStub](api/components/RouterLinkStub.md)
* [セレクタ](api/selectors.md)
* [createWrapper](api/createWrapper.md)
* [createLocalVue](api/createLocalVue.md)
* [config](api/config.md)
3 changes: 2 additions & 1 deletion docs/ja/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
!!!include(docs/ja/api/renderToString.md)!!!
!!!include(docs/ja/api/selectors.md)!!!
!!!include(docs/ja/api/createLocalVue.md)!!!
!!!include(docs/ja/api/config.md)!!!
!!!include(docs/ja/api/createWrapper.md)!!!
!!!include(docs/ja/api/config.md)!!!
25 changes: 25 additions & 0 deletions docs/ja/api/createWrapper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## createWrapper(node [, options])

- **引数:**

- `{vm|HTMLElement} node`
- `{Object} options`
- `{Boolean} sync`
- `{Boolean} attachedToDocument`

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

- **使い方:**

`createWrapper` は Vue インスタンスまたは HTML 要素に対する `Wrapper` を生成します。

```js
import { createWrapper } from '@vue/test-utils'
import Foo from './Foo.vue'

const Constructor = Vue.extend(Foo)
const vm = new Constructor().$mount()
const wrapper = createWrapper(vm)
expect(wrapper.vm.foo).toBe(true)
```
34 changes: 30 additions & 4 deletions docs/ja/api/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [`attachToDocument`](#attachtodocument)
- [`attrs`](#attrs)
- [`listeners`](#listeners)
- [`parentComponent`](#parentComponent)
- [`provide`](#provide)
- [`sync`](#sync)

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

```js
import Foo from './Foo.vue'
import Bar from './Bar.vue'

const bazComponent = {
name: 'baz-component',
template: '<p>baz</p>'
}

const wrapper = shallowMount(Component, {
slots: {
default: [Foo, Bar],
fooBar: Foo, // Will match <slot name="FooBar" />,
foo: '<div />'
default: [Foo, '<my-component />', 'text'],
fooBar: Foo, // `<slot name="FooBar" />` にマッチします。
foo: '<div />',
bar: 'bar',
baz: bazComponent,
qux: '<my-component />'
}
})

expect(wrapper.find('div')).toBe(true)
```

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

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

## parentComponent

- 型: `Object`

マウントされるコンポーネントの親コンポーネントとして使用されるコンポーネントです。

例:

```js
import Foo from './Foo.vue'

const wrapper = shallowMount(Component, {
parentComponent: Foo
})
expect(wrapper.vm.$parent.name).toBe('foo')
```

## provide

- 型: `Object`
Expand Down
4 changes: 2 additions & 2 deletions docs/ja/api/wrapper/setChecked.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { mount } from '@vue/test-utils'
import Foo from './Foo.vue'

const wrapper = mount(Foo)
const option = wrapper.find('input[type="radio"]')
option.setChecked()
const radioInput = wrapper.find('input[type="radio"]')
radioInput.setChecked()
```

- **注:**
Expand Down
2 changes: 2 additions & 0 deletions docs/ja/api/wrapper/setData.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

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

setData は再帰的に Vue.set を実行することで動作します。

**Wrapper には Vue インスタンスを含む必要があることに注意してください**

- **引数:**
Expand Down
26 changes: 19 additions & 7 deletions docs/ja/api/wrapper/setValue.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,27 @@ import { mount } from '@vue/test-utils'
import Foo from './Foo.vue'

const wrapper = mount(Foo)
const input = wrapper.find('input[type="text"]')
input.setValue('some value')

const textInput = wrapper.find('input[type="text"]')
textInput.setValue('some value')

const select = wrapper.find('select')
select.setValue('option value')
```


- **注:**

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

```js
textInput.element.value = value
textInput.trigger('input')
```
```js
textInput.element.value = value
textInput.trigger('input')
```

- `select.setValue(value)` は以下のコードのエイリアスです。

```js
select.element.value = value
select.trigger('change')
```