瀏覽代碼

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

Jokcy 8 年之前
父節點
當前提交
9420e2bf53
共有 5 個文件被更改,包括 15 次插入15 次删除
  1. 3 3
      docs/en/testing.md
  2. 3 3
      docs/fr/testing.md
  3. 3 3
      docs/ja/testing.md
  4. 3 3
      docs/ru/testing.md
  5. 3 3
      docs/zh-cn/testing.md

+ 3 - 3
docs/en/testing.md

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