Skip to content

Commit 3cebcb3

Browse files
committed
Merge branch 'patch-1' of github.com:gitlab-winnie/vuex into gitlab-winnie-patch-1
2 parents 22d4a1e + 677e69a commit 3cebcb3

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/en/testing.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,24 @@ describe('actions', () => {
128128
})
129129
```
130130

131+
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:
132+
133+
``` js
134+
describe('actions', () => {
135+
it('getAllProducts', () => {
136+
const commit = sinon.spy()
137+
const state = {}
138+
139+
actions.getAllProducts({ commit, state })
140+
141+
expect(commit.args).to.deep.equal([
142+
[ 'REQUEST_PRODUCTS' ],
143+
[ 'RECEIVE_PRODUCTS', { /* mocked response */ } ]
144+
])
145+
})
146+
})
147+
```
148+
131149
### Testing Getters
132150

133151
If your getters have complicated computation, it is worth testing them. Getters are also very straightforward to test as same reason as mutations.

0 commit comments

Comments
 (0)