summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorWinnie Hellmann <winnie@gitlab.com>2018-05-18 08:39:42 +0000
committerWinnie Hellmann <winnie@gitlab.com>2018-05-18 08:39:42 +0000
commit7feef84e1e60bef5cd460345125cc83dd23350cc (patch)
treeb5cc5b447d3cd64e6bde67e2a84b0b870d726769 /doc
parent769c4a6197dfd72aca06abd20fa1ffe5c568ed24 (diff)
downloadgitlab-ce-7feef84e1e60bef5cd460345125cc83dd23350cc.tar.gz
Make stores export a createStore() which can be used in testswinh-vuex-createStore-docs
Diffstat (limited to 'doc')
-rw-r--r--doc/development/fe_guide/vuex.md8
1 files changed, 6 insertions, 2 deletions
diff --git a/doc/development/fe_guide/vuex.md b/doc/development/fe_guide/vuex.md
index 8997a5889dc..858b03c60bf 100644
--- a/doc/development/fe_guide/vuex.md
+++ b/doc/development/fe_guide/vuex.md
@@ -37,12 +37,13 @@ import state from './state';
Vue.use(Vuex);
-export default new Vuex.Store({
+export const createStore = () => new Vuex.Store({
actions,
getters,
mutations,
state,
});
+export default createStore();
```
### `state.js`
@@ -320,10 +321,11 @@ In order to write unit tests for those components, we need to include the store
```javascript
//component_spec.js
import Vue from 'vue';
-import store from './store';
+import { createStore } from './store';
import component from './component.vue'
describe('component', () => {
+ let store;
let vm;
let Component;
@@ -340,6 +342,8 @@ describe('component', () => {
name: 'Foo',
age: '30',
};
+
+ store = createStore();
// populate the store
store.dispatch('addUser', user);