Skip to content

Commit 92e7e90

Browse files
committed
translate api/options.md
1 parent 50052e1 commit 92e7e90

File tree

1 file changed

+79
-124
lines changed

1 file changed

+79
-124
lines changed

docs/ja/api/options.md

Lines changed: 79 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,114 @@
1-
# options
1+
# マウンティングオプション
22

3-
Options for mount and shallow. The options object can contain vue-test-utils options and Vue options together.
3+
`mount``shallow`オプション。optionsオブジェクトには、`vue-test-utils`のマウントオプションと生のVueオプションの両方を含めることができます。
44

5-
Vue options are passed to the component when a new instance is created. , e.g. `store`, `propsData`. For full list, see the [Vue API](https://vuejs.org/v2/api/). Also takes vue-test-utils options:
5+
新しくインスタンスが作成されると、Vueオプションがコンポーネントに渡されます。例:`store``propsData`など。完全なリストについては[Vue API docs](https://vuejs.org/v2/api/)を参照してください。
66

7-
- **Options:**
7+
## `vue-test-utils`の詳細なマウンティングオプション
88

9-
- `{Object} options`
10-
- `{boolean} attachToDocument`
11-
- `{Object} attrs`
12-
- `{Object} children`
13-
- `{boolean} clone`
14-
- `{Object} context`
15-
- `{Object} intercept`
16-
- `{Vue} localVue`
17-
- `{Object} slots`
18-
- `{Array<Componet|Object>|Component|String} default`
19-
- `{Array<Componet|Object>|Component|String} named`
20-
- `{Object|Array<string>} stubs`
21-
- `{Object|Function} provide`
9+
- [context](#context)
10+
- [slots](#slots)
11+
- [stubs](#stubs)
12+
- [mocks](#mocks)
13+
- [localVue](#localvue)
14+
- [attachToDocument](#attachtodocument)
15+
- [attrs](#attrs)
16+
- [listeners](#listeners)
17+
- [clone](#clone)
2218

23-
`options` (`Object`): a Vue options object. Vue options are passed to the component when a new instance is created. , e.g. `store`, `propsData`. For full list, see the [Vue API](https://vuejs.org/v2/api/). Also takes vue-test-utils options:
19+
### `context`
2420

25-
`options.attachToDocument` (`boolean`): Component will attach to DOM when rendered. This can be used with [`hasStyle`](/docs/en/api/wrapper/hasStyle.md) to check multi element CSS selectors
21+
- 型: `Object`
2622

27-
`options.attrs` (`Object`): Attrs object to pass to component.
23+
コンテキストを機能コンポーネントに渡します。 機能コンポーネントのみで使用できます。
2824

29-
`options.children` (`Array<string|Component|Function>`): Passes children to be rendered by functional components
25+
例:
3026

31-
`options.clone` (`boolean`): Clones component before editing if `true`, does not if `false`. Defaults to `true`
32-
33-
`options.context` (`Object`): Passes context to functional component. Can only be used with functional components
34-
35-
`options.intercept` (`Object`): Add globals to Vue instance.
36-
37-
`options.localVue` (`Object`): vue class to use in `mount`. See [createLocalVue](/docs/en/api/createLocalVue.md)
38-
39-
`options.propsData` (`Object`): Data for props in component
40-
41-
`options.slots` (`Object`): Render component with slots.
42-
43-
`options.slots.default` (`Array[Component]|Component|String`): Default slot object to render, can be a Vue component or array of Vue components
27+
```js
28+
const wrapper = mount(Component, {
29+
context: {
30+
props: { show: true }
31+
}
32+
})
4433

45-
`options.slots.name` (`Array[Component]|Component`): Named slots. i.e. slots.name will match a <slot name="name" />, can be a Vue component or array of Vue components
34+
expect(wrapper.is(Component)).toBe(true)
35+
```
4636

47-
`options.stubs` (`Object|Array<string>`): Stubs components matching the name. Takes object or array of strings
37+
### `slots`
4838

49-
`options.provide` (`Object`): Provides value to component
39+
- 型: `{ [name: string]: Array<Component>|Component|string }`
5040

51-
- **Usage:**
41+
コンポーネントにスロットコンテンツのオブジェクトを渡します。keyはスロット名に対応します。値は、コンポーネント、コンポーネントの配列、またはテンプレート文字列のいずれかです。
5242

53-
**With Vue options:**
43+
例:
5444

5545
```js
5646
import { expect } from 'chai'
47+
import Foo from './Foo.vue'
48+
import Bar from './Bar.vue'
5749

5850
const wrapper = shallow(Component, {
59-
propsData: {
60-
color: 'red'
51+
slots: {
52+
default: [Foo, Bar],
53+
fooBar: Foo, // Will match <slot name="FooBar" />,
54+
foo: '<div />'
6155
}
6256
})
63-
expect(wrapper.hasProp('color', 'red')).to.equal(true)
57+
expect(wrapper.find('div')).toBe(true)
6458
```
6559

66-
**Do not clone component**
67-
68-
```js
69-
import { expect } from 'chai'
60+
### `stubs`
7061

71-
const wrapper = mount(Component, {
72-
clone: false
73-
})
62+
- type: `{ [name: string]: Component | boolean } | Array<string>`
7463

75-
expect(wrapper.hasProp('color', 'red')).to.equal(true)
76-
```
64+
子のコンポーネントをスタブします。スタブまたはオブジェクトに対するコンポーネント名の配列になります。
7765

78-
**Attach to DOM:**
66+
例:
7967

8068
```js
81-
import { expect } from 'chai'
69+
import Foo from './Foo.vue'
8270

83-
const wrapper = shallow(Component, {
84-
attachToDocument: true
71+
mount(Component, {
72+
stubs: ['registered-component']
8573
})
86-
expect(wrapper.contains('div')).to.equal(true)
87-
```
88-
89-
**Pass attrs:**
9074

91-
```js
9275
shallow(Component, {
93-
attrs: {
94-
attribute: 'value'
76+
stubs: {
77+
// 特定の実装によるスタブ
78+
'registered-component': Foo,
79+
// デフォルトのスタブを作成します
80+
'another-component': true
9581
}
9682
})
9783
```
9884

99-
**Mount a functional component:**
85+
### `mocks`
10086

101-
```js
102-
import { expect } from 'chai'
87+
- 型: `Object`
10388

104-
const wrapper = mount(Component, {
105-
context: {
106-
props: { show: true }
107-
}
108-
})
109-
110-
expect(wrapper.is(Component)).to.equal(true)
111-
```
89+
インスタンスに追加のプロパティを追加します。グローバル注入をモックするのに便利です。
11290

113-
**Stub global properties:**
91+
例:
11492

11593
```js
11694
import { expect } from 'chai'
11795

11896
const $route = { path: 'http://www.example-path.com' }
11997
const wrapper = shallow(Component, {
120-
intercept: {
98+
mocks: {
12199
$route
122100
}
123101
})
124-
expect(wrapper.vm.$route.path).to.equal($route.path)
102+
expect(wrapper.vm.$route.path).toBe($route.path)
125103
```
126104

127-
**Install Vue Router with a local Vue:**
105+
### `localVue`
106+
107+
- 型: `Vue`
108+
109+
コンポーネントのマウント時に使用する[createLocalVue](./createLocalVue.md)によって作成されたVueのローカルコピーです。
110+
111+
例:
128112

129113
```js
130114
import { createLocalVue, mount } from 'vue-test-utils'
@@ -147,64 +131,35 @@ const wrapper = mount(Component, {
147131
localVue,
148132
router
149133
})
150-
expect(wrapper.vm.$route).to.be.an('object')
134+
expect(wrapper.vm.$route).toBeInstanceOf(Object)
151135
```
152136

153-
**Default and named slots:**
137+
### `attachToDocument`
154138

155-
```js
156-
import { expect } from 'chai'
157-
import Foo from './Foo.vue'
158-
import Bar from './Bar.vue'
139+
- 型: `boolean`
140+
- デフォルト: `false`
159141

160-
const wrapper = shallow(Component, {
161-
slots: {
162-
default: [Foo, Bar],
163-
fooBar: Foo, // Will match <slot name="FooBar" />,
164-
foo: '<div />'
165-
}
166-
})
167-
expect(wrapper.find('div')).to.equal(true)
168-
```
142+
`true`に設定されている場合、レンダリング時にコンポーネントはDOMにアタッチされます。これは複数の要素やCSSセレクタをチェックするための[`hasStyle`](wrapper/hasStyle.md)とも使用できます。
169143

170-
**Stub components:**
144+
### `attrs`
171145

172-
```js
173-
import Foo from './Foo.vue'
146+
- 型: `Object`
174147

175-
mount(Component, {
176-
stubs: ['registered-component']
177-
})
148+
コンポーネントインスタンスの`$attrs`オブジェクトを設定します。
178149

179-
shallow(Component, {
180-
stubs: {
181-
'registered-component': Foo,
182-
'another-component': true
183-
}
184-
})
185-
```
150+
### `listeners`
186151

187-
**Provide data to components:**
152+
- 型: `Object`
188153

189-
```js
190-
import { expect } from 'chai'
154+
コンポーネントインスタンスの`$listeners`オブジェクトを設定します。
191155

192-
const wrapper = mount(Component, {
193-
provide: { fromMount: 'functionValue' }
194-
})
195-
expect(wrapper.text()).to.contain('functionValue')
196-
```
156+
### `clone`
197157

198-
**Provide data to components:**
158+
- 型: `boolean`
159+
- デフォルト: `true`
199160

200-
```js
201-
const wrapper = shallow(Component, {
202-
provide () {
203-
return {
204-
fromMount: 'functionValue'
205-
}
206-
}
207-
})
161+
`true`に設定されている場合、マウント前にコンポーネントを複製し、元のコンポーネントの定義を変更することはありません。
208162

209-
expect(wrapper.text()).to.contain('functionValue')
210-
```
163+
`options.mocks` (`Object`): Vueインスタンスにグローバルを追加します。
164+
165+
`options.localVue` (`Object`): `mount`で使うVueクラスです。[createLocalVue](createLocalVue.md)を参照してください。

0 commit comments

Comments
 (0)