Skip to content

Commit e767e00

Browse files
committed
test(store): add auth and async tests
1 parent 82f4654 commit e767e00

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
});

0 commit comments

Comments
 (0)