Skip to content

Commit 7bcfae1

Browse files
committed
translate vuex using section
1 parent 3984871 commit 7bcfae1

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed

docs/ja/guides/using-with-vuex.md

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Using with Vuex
1+
# Vuex と一緒に使用する
22

3-
In this guide, we'll see how to test Vuex in components with vue-test-utils.
3+
このガイドでは、vue-test-utils でコンポーネントで Vuex をテストする方法について、見ていきます。
44

5-
## Mocking Actions
5+
## アクションのモック
66

7-
Let’s look at some code.
7+
それではいくつかのコードを見ていきましょう。
88

9-
This is the component we want to test. It calls Vuex actions.
9+
これはテストしたいコンポーネントです。これは Vuex のアクションを呼び出します。
1010

1111
``` html
1212
<template>
@@ -35,13 +35,13 @@ export default{
3535
</script>
3636
```
3737

38-
For the purposes of this test, we don’t care what the actions do, or what the store looks like. We just need to know that these actions are being fired when they should, and that they are fired with the expected value.
38+
このテストの目的のために、アクションが何をしているのか、またはストアがどのように見えるかは気にしません。これらのアクションが必要なときに発行されていること、そして期待された値によって発行されていることを知ることが必要です。
3939

40-
To test this, we need to pass a mock store to Vue when we shallow our component.
40+
これをテストするためには、私たちのコンポーネントを shallow するときに Vue にモックストアを渡す必要があります。
4141

42-
Instead of passing the store to the base Vue constructor, we can pass it to a - [localVue](../api/options.md#localvue). A localVue is a scoped Vue constructor that we can make changes to without affecting the global Vue constructor.
42+
ストアを Vue コンストラクタベースに渡す代わりに、[localVue](../api/options.md#localvue) に渡すことができます。localeVue はグローバルな Vue コンストラクタに影響を与えずに、変更を加えることができるスコープ付き Vue コンストラクタです。
4343

44-
Let’s see what this looks like:
44+
これがどのように見えるか見ていきましょう:
4545

4646
``` js
4747
import { shallow, createLocalVue } from 'vue-test-utils'
@@ -91,23 +91,23 @@ describe('Actions.vue', () => {
9191
})
9292
```
9393

94-
What’s happening here? First we tell Vue to use Vuex with the Vue.use method. This is just a wrapper around Vue.use.
94+
ここでは何が起こっているでしょうか?まず、Vue Vue.use メソッドを使用して Vuex を使用するように支持しています。これは、単なる Vue.use のラッパです。
9595

96-
We then make a mock store by calling new Vuex.store with our mock values. We only pass it the actions, since that’s all we care about.
96+
次に、新しい Vuex.store をモックされた値で呼び出すことによってモックストアを呼び出します。それは全て気にすることであるので、それをアクションに渡すだけです。
9797

98-
The actions are [jest mock functions](https://facebook.github.io/jest/docs/en/mock-functions.html). These mock functions give us methods to assert whether the actions were called or not.
98+
アクションは、[jest のモック関数](https://facebook.github.io/jest/docs/en/mock-functions.html)です。これらモック関数は、アクションが呼び出された、または呼び出されていない、かどうかを検証するメソッドを提供します。
9999

100-
We can then assert in our tests that the action stub was called when expected.
100+
アクションのスタブが期待どおりに呼び出されたことを検討することができます。
101101

102-
Now the way we define the store might look a bit foreign to you.
102+
今、ストアを定義する方法が、あなたには少し外に見えるかもしれません。
103103

104-
We’re using beforeEach to ensure we have a clean store before each test. beforeEach is a mocha hook that’s called before each test. In our test, we are reassigning the store variables value. If we didn’t do this, the mock functions would need to be automatically reset. It also lets us change the state in our tests, without it affecting later tests.
104+
各テストより前にストアをクリーンに保証するために、beofreEach を使用しています。beforeEach は各テストより前に呼び出される mocha のフックです。このテストでは、ストア変数に値を再度割り当てています。これをしていない場合は、モック関数は自動的にリセットされる必要があります。また、テストにおいて状態を変更することもできますが、この方法は、後のテストで影響を与えることはないです。
105105

106-
The most important thing to note in this test is that **we create a mock Vuex store and then pass it to vue-test-utils**.
106+
このテストで最も重要なことは、**モック Vuex ストアを作成し、それを vue-test-utils に渡す** ことです。
107107

108-
Great, so now we can mock actions, let’s look at mocking getters.
108+
素晴らしい!今、アクションをモック化できるので、ゲッタのモックについて見ていきましょう。
109109

110-
## Mocking Getters
110+
## ゲッタのモック
111111

112112

113113
``` html
@@ -130,9 +130,9 @@ export default{
130130
</script>
131131
```
132132

133-
This is a fairly simple component. It renders the result of the getters clicks and inputValue. Again, we don’t really care about what those getters returns – just that the result of them is being rendered correctly.
133+
これは、かなり単純なコンポーネントです。ゲッタによる clicks の結果と inputValue を描画します。また、これらゲッタが返す値については実際に気にしません。それらの結果が正しく描画されているかだけです。
134134

135-
Let’s see the test:
135+
テストを見てみましょう:
136136

137137
``` js
138138
import { shallow, createLocalVue } from 'vue-test-utils'
@@ -171,15 +171,16 @@ describe('Getters.vue', () => {
171171
})
172172
})
173173
```
174-
This test is similar to our actions test. We create a mock store before each test, pass it as an option when we call shallow, and assert that the value returned by our mock getters is being rendered.
175174

176-
This is great, but what if we want to check our getters are returning the correct part of our state?
175+
このテストはアクションのテストに似ています。各テストの前にモックストアを作成し、shallow を呼び出すときにオプションを渡し、そしてモックゲッタから返された値を描画されているのを検証します。
177176

178-
## Mocking with Modules
177+
これは素晴らしいですが、もしゲッタが状態の正しい部分を返しているのを確認したい場合はどうしますか?
179178

180-
[Modules](https://vuex.vuejs.org/en/modules.html) are useful for separating out our store into manageable chunks. They also export getters. We can use these in our tests.
179+
## モジュールによるモック
181180

182-
Let’s look at our component:
181+
[モジュール](https://vuex.vuejs.org/en/modules.html)はストアを管理しやすい塊に分けるために便利です。それらはゲッタもエクスポートします。テストではこれらを使用することができます。
182+
183+
コンポーネントを見てみましょう:
183184

184185
``` html
185186
<template>
@@ -205,9 +206,10 @@ export default{
205206
}
206207
</script>
207208
```
208-
Simple component that includes one action and one getter.
209209

210-
And the test:
210+
1 つのアクションと 1 つのゲッタを含む単純なコンポーネントです。
211+
212+
そしてテストは以下のようになります:
211213

212214
``` js
213215
import { shallow, createLocalVue } from 'vue-test-utils'
@@ -257,8 +259,8 @@ describe('Modules.vue', () => {
257259
})
258260
```
259261

260-
### Resources
262+
### リソース
261263

262-
- [Example project for this guide](https://github.com/eddyerburgh/vue-test-utils-vuex-example)
264+
- [このガイド向けの例](https://github.com/eddyerburgh/vue-test-utils-vuex-example)
263265
- [localVue](../api/options.md#localvue)
264266
- [createLocalVue](../api/createLocalVue.md)

0 commit comments

Comments
 (0)