Skip to content

Commit 9420e2b

Browse files
Jokcyktsn
authored andcommitted
update testing doc: commit to mutation not dispatch (#512)
1 parent 5c132de commit 9420e2b

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

docs/en/testing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ Example testing an async action:
5757
// actions.js
5858
import shop from '../api/shop'
5959

60-
export const getAllProducts = ({ dispatch }) => {
61-
dispatch('REQUEST_PRODUCTS')
60+
export const getAllProducts = ({ commit }) => {
61+
commit('REQUEST_PRODUCTS')
6262
shop.getProducts(products => {
63-
dispatch('RECEIVE_PRODUCTS', products)
63+
commit('RECEIVE_PRODUCTS', products)
6464
})
6565
}
6666
```

docs/fr/testing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ Exemple de test d'une action asynchrone :
5757
// actions.js
5858
import shop from '../api/shop'
5959

60-
export const getAllProducts = ({ dispatch }) => {
61-
dispatch('REQUEST_PRODUCTS')
60+
export const getAllProducts = ({ commit }) => {
61+
commit('REQUEST_PRODUCTS')
6262
shop.getProducts(products => {
63-
dispatch('RECEIVE_PRODUCTS', products)
63+
commit('RECEIVE_PRODUCTS', products)
6464
})
6565
}
6666
```

docs/ja/testing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ describe('mutations', () => {
5757
// actions.js
5858
import shop from '../api/shop'
5959

60-
export const getAllProducts = ({ dispatch }) => {
61-
dispatch('REQUEST_PRODUCTS')
60+
export const getAllProducts = ({ commit }) => {
61+
commit('REQUEST_PRODUCTS')
6262
shop.getProducts(products => {
63-
dispatch('RECEIVE_PRODUCTS', products)
63+
commit('RECEIVE_PRODUCTS', products)
6464
})
6565
}
6666
```

docs/ru/testing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ describe('mutations', () => {
5757
// actions.js
5858
import shop from '../api/shop'
5959

60-
export const getAllProducts = ({ dispatch }) => {
61-
dispatch('REQUEST_PRODUCTS')
60+
export const getAllProducts = ({ commit }) => {
61+
commit('REQUEST_PRODUCTS')
6262
shop.getProducts(products => {
63-
dispatch('RECEIVE_PRODUCTS', products)
63+
commit('RECEIVE_PRODUCTS', products)
6464
})
6565
}
6666
```

docs/zh-cn/testing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ Actions 应对起来略微棘手,因为它们可能需要调用外部的 API
5757
// actions.js
5858
import shop from '../api/shop'
5959

60-
export const getAllProducts = ({ dispatch }) => {
61-
dispatch('REQUEST_PRODUCTS')
60+
export const getAllProducts = ({ commit }) => {
61+
commit('REQUEST_PRODUCTS')
6262
shop.getProducts(products => {
63-
dispatch('RECEIVE_PRODUCTS', products)
63+
commit('RECEIVE_PRODUCTS', products)
6464
})
6565
}
6666
```

0 commit comments

Comments
 (0)