1
0
Эх сурвалжийг харах

update testing doc: commit to mutation not dispatch (#512)

Jokcy 8 жил өмнө
parent
commit
9420e2bf53

+ 3 - 3
docs/en/testing.md

@@ -57,10 +57,10 @@ Example testing an async action:
 // actions.js
 import shop from '../api/shop'
 
-export const getAllProducts = ({ dispatch }) => {
-  dispatch('REQUEST_PRODUCTS')
+export const getAllProducts = ({ commit }) => {
+  commit('REQUEST_PRODUCTS')
   shop.getProducts(products => {
-    dispatch('RECEIVE_PRODUCTS', products)
+    commit('RECEIVE_PRODUCTS', products)
   })
 }
 ```

+ 3 - 3
docs/fr/testing.md

@@ -57,10 +57,10 @@ Exemple de test d'une action asynchrone :
 // actions.js
 import shop from '../api/shop'
 
-export const getAllProducts = ({ dispatch }) => {
-  dispatch('REQUEST_PRODUCTS')
+export const getAllProducts = ({ commit }) => {
+  commit('REQUEST_PRODUCTS')
   shop.getProducts(products => {
-    dispatch('RECEIVE_PRODUCTS', products)
+    commit('RECEIVE_PRODUCTS', products)
   })
 }
 ```

+ 3 - 3
docs/ja/testing.md

@@ -57,10 +57,10 @@ describe('mutations', () => {
 // actions.js
 import shop from '../api/shop'
 
-export const getAllProducts = ({ dispatch }) => {
-  dispatch('REQUEST_PRODUCTS')
+export const getAllProducts = ({ commit }) => {
+  commit('REQUEST_PRODUCTS')
   shop.getProducts(products => {
-    dispatch('RECEIVE_PRODUCTS', products)
+    commit('RECEIVE_PRODUCTS', products)
   })
 }
 ```

+ 3 - 3
docs/ru/testing.md

@@ -57,10 +57,10 @@ describe('mutations', () => {
 // actions.js
 import shop from '../api/shop'
 
-export const getAllProducts = ({ dispatch }) => {
-  dispatch('REQUEST_PRODUCTS')
+export const getAllProducts = ({ commit }) => {
+  commit('REQUEST_PRODUCTS')
   shop.getProducts(products => {
-    dispatch('RECEIVE_PRODUCTS', products)
+    commit('RECEIVE_PRODUCTS', products)
   })
 }
 ```

+ 3 - 3
docs/zh-cn/testing.md

@@ -57,10 +57,10 @@ Actions 应对起来略微棘手,因为它们可能需要调用外部的 API
 // actions.js
 import shop from '../api/shop'
 
-export const getAllProducts = ({ dispatch }) => {
-  dispatch('REQUEST_PRODUCTS')
+export const getAllProducts = ({ commit }) => {
+  commit('REQUEST_PRODUCTS')
   shop.getProducts(products => {
-    dispatch('RECEIVE_PRODUCTS', products)
+    commit('RECEIVE_PRODUCTS', products)
   })
 }
 ```