File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
template/client/store/modules Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ import { createLocalVue } from 'vue-test-utils' ;
2+ import Vuex from 'vuex' ;
3+ import async from './index' ;
4+
5+ const Vue = createLocalVue ( ) ;
6+ Vue . use ( Vuex ) ;
7+
8+ describe ( 'async module' , ( ) => {
9+ const initialState = JSON . stringify ( async . state ) ;
10+ const store = new Vuex . Store ( async ) ;
11+
12+ beforeEach ( ( ) => {
13+ store . replaceState ( JSON . parse ( initialState ) ) ;
14+ } ) ;
15+
16+ it ( 'has ajaxCommands state' , ( ) => {
17+ expect ( store . state . ajaxCommands ) . toEqual ( [ ] ) ;
18+ } ) ;
19+
20+ it ( 'adds command to ajaxCommands' , ( ) => {
21+ const cmd = 'foo' ;
22+ store . commit ( 'addAjaxCommand' , cmd ) ;
23+ expect ( store . state . ajaxCommands ) . toContain ( cmd ) ;
24+ expect ( store . getters . loadingAjax ) . toBeTruthy ( ) ;
25+ } ) ;
26+
27+ it ( 'remove command from ajaxCommands' , ( ) => {
28+ const cmd = 'foo' ;
29+ store . commit ( 'addAjaxCommand' , cmd ) ;
30+ store . commit ( 'removeAjaxCommand' , cmd ) ;
31+ expect ( store . state . ajaxCommands ) . not . toContain ( cmd ) ;
32+ expect ( store . getters . loadingAjax ) . not . toBeTruthy ( ) ;
33+ } ) ;
34+ } ) ;
Original file line number Diff line number Diff line change 1+ import * as mutations from './mutations' ;
2+
3+ describe ( 'auth mutations' , ( ) => {
4+ it ( 'set access_token' , ( ) => {
5+ const state = { } ;
6+ mutations . setAccessToken ( state , 'foo' ) ;
7+ expect ( state . access_token ) . toEqual ( 'foo' ) ;
8+ } ) ;
9+
10+ it ( 'set account' , ( ) => {
11+ const state = { } ;
12+ mutations . setAccount ( state , 'foo' ) ;
13+ expect ( state . account ) . toEqual ( 'foo' ) ;
14+ } ) ;
15+ } ) ;
You can’t perform that action at this time.
0 commit comments