1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
import statuses from '~/user_lists/constants/edit';
import createState from '~/user_lists/store/edit/state';
import * as types from '~/user_lists/store/edit/mutation_types';
import mutations from '~/user_lists/store/edit/mutations';
import { userList } from '../../../feature_flags/mock_data';
describe('User List Edit Mutations', () => {
let state;
beforeEach(() => {
state = createState({ projectId: '1', userListIid: '2' });
});
describe(types.REQUEST_USER_LIST, () => {
beforeEach(() => {
mutations[types.REQUEST_USER_LIST](state);
});
it('sets the state to loading', () => {
expect(state.status).toBe(statuses.LOADING);
});
});
describe(types.RECEIVE_USER_LIST_SUCCESS, () => {
beforeEach(() => {
mutations[types.RECEIVE_USER_LIST_SUCCESS](state, userList);
});
it('sets the state to success', () => {
expect(state.status).toBe(statuses.SUCCESS);
});
it('sets the user list to the one received', () => {
expect(state.userList).toEqual(userList);
});
});
describe(types.RECIEVE_USER_LIST_ERROR, () => {
beforeEach(() => {
mutations[types.RECEIVE_USER_LIST_ERROR](state, ['network error']);
});
it('sets the state to error', () => {
expect(state.status).toBe(statuses.ERROR);
});
it('sets the error message to the recieved one', () => {
expect(state.errorMessage).toEqual(['network error']);
});
});
describe(types.DISMISS_ERROR_ALERT, () => {
beforeEach(() => {
mutations[types.DISMISS_ERROR_ALERT](state);
});
it('sets the state to error dismissed', () => {
expect(state.status).toBe(statuses.UNSYNCED);
});
});
});
|