Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
7feef84e
Commit
7feef84e
authored
May 18, 2018
by
Winnie Hellmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make stores export a createStore() which can be used in tests
parent
769c4a61
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
doc/development/fe_guide/vuex.md
doc/development/fe_guide/vuex.md
+6
-2
No files found.
doc/development/fe_guide/vuex.md
View file @
7feef84e
...
@@ -37,12 +37,13 @@ import state from './state';
...
@@ -37,12 +37,13 @@ import state from './state';
Vue
.
use
(
Vuex
);
Vue
.
use
(
Vuex
);
export
default
new
Vuex
.
Store
({
export
const
createStore
=
()
=>
new
Vuex
.
Store
({
actions
,
actions
,
getters
,
getters
,
mutations
,
mutations
,
state
,
state
,
});
});
export
default
createStore
();
```
```
### `state.js`
### `state.js`
...
@@ -320,10 +321,11 @@ In order to write unit tests for those components, we need to include the store
...
@@ -320,10 +321,11 @@ In order to write unit tests for those components, we need to include the store
```
javascript
```
javascript
//component_spec.js
//component_spec.js
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
store
from
'
./store
'
;
import
{
createStore
}
from
'
./store
'
;
import
component
from
'
./component.vue
'
import
component
from
'
./component.vue
'
describe
(
'
component
'
,
()
=>
{
describe
(
'
component
'
,
()
=>
{
let
store
;
let
vm
;
let
vm
;
let
Component
;
let
Component
;
...
@@ -340,6 +342,8 @@ describe('component', () => {
...
@@ -340,6 +342,8 @@ describe('component', () => {
name
:
'
Foo
'
,
name
:
'
Foo
'
,
age
:
'
30
'
,
age
:
'
30
'
,
};
};
store
=
createStore
();
// populate the store
// populate the store
store
.
dispatch
(
'
addUser
'
,
user
);
store
.
dispatch
(
'
addUser
'
,
user
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment