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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
import * as types from '~/ide/stores/modules/terminal_sync/mutation_types';
import mutations from '~/ide/stores/modules/terminal_sync/mutations';
import createState from '~/ide/stores/modules/terminal_sync/state';
const TEST_MESSAGE = 'lorem ipsum dolar sit';
describe('ide/stores/modules/terminal_sync/mutations', () => {
let state;
beforeEach(() => {
state = createState();
});
describe(types.START_LOADING, () => {
it('sets isLoading and resets error', () => {
Object.assign(state, {
isLoading: false,
isError: true,
});
mutations[types.START_LOADING](state);
expect(state).toEqual(
expect.objectContaining({
isLoading: true,
isError: false,
}),
);
});
});
describe(types.SET_ERROR, () => {
it('sets isLoading and error message', () => {
Object.assign(state, {
isLoading: true,
isError: false,
message: '',
});
mutations[types.SET_ERROR](state, { message: TEST_MESSAGE });
expect(state).toEqual(
expect.objectContaining({
isLoading: false,
isError: true,
message: TEST_MESSAGE,
}),
);
});
});
describe(types.SET_SUCCESS, () => {
it('sets isLoading and resets error and is started', () => {
Object.assign(state, {
isLoading: true,
isError: true,
isStarted: false,
});
mutations[types.SET_SUCCESS](state);
expect(state).toEqual(
expect.objectContaining({
isLoading: false,
isError: false,
isStarted: true,
}),
);
});
});
describe(types.STOP, () => {
it('sets stop values', () => {
Object.assign(state, {
isLoading: true,
isStarted: true,
});
mutations[types.STOP](state);
expect(state).toEqual(
expect.objectContaining({
isLoading: false,
isStarted: false,
}),
);
});
});
});
|