浏览代码

Merge branch 'patch-1' of github.com:gitlab-winnie/vuex into gitlab-winnie-patch-1

ktsn 7 年之前
父节点
当前提交
3cebcb3854
共有 1 个文件被更改,包括 18 次插入0 次删除
  1. 18 0
      docs/en/testing.md

+ 18 - 0
docs/en/testing.md

@@ -128,6 +128,24 @@ describe('actions', () => {
 })
 })
 ```
 ```
 
 
+If you have spies available in your testing environment (for example via [Sinon.JS](http://sinonjs.org/)), you can use them instead of the `testAction` helper:
+
+``` js
+describe('actions', () => {
+  it('getAllProducts', () => {
+    const commit = sinon.spy()
+    const state = {}
+    
+    actions.getAllProducts({ commit, state })
+    
+    expect(commit.args).to.deep.equal([
+      [ 'REQUEST_PRODUCTS' ],
+      [ 'RECEIVE_PRODUCTS', { /* mocked response */ } ]
+    ])
+  })
+})
+```
+
 ### Testing Getters
 ### Testing Getters
 
 
 If your getters have complicated computation, it is worth testing them. Getters are also very straightforward to test as same reason as mutations.
 If your getters have complicated computation, it is worth testing them. Getters are also very straightforward to test as same reason as mutations.