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
|
import createStore from '~/reports/accessibility_report/store';
import mutations from '~/reports/accessibility_report/store/mutations';
describe('Accessibility Reports mutations', () => {
let localState;
let localStore;
beforeEach(() => {
localStore = createStore();
localState = localStore.state;
});
describe('SET_ENDPOINT', () => {
it('sets endpoint to given value', () => {
const endpoint = 'endpoint.json';
mutations.SET_ENDPOINT(localState, endpoint);
expect(localState.endpoint).toEqual(endpoint);
});
});
describe('REQUEST_REPORT', () => {
it('sets isLoading to true', () => {
mutations.REQUEST_REPORT(localState);
expect(localState.isLoading).toEqual(true);
});
});
describe('RECEIVE_REPORT_SUCCESS', () => {
it('sets isLoading to false', () => {
mutations.RECEIVE_REPORT_SUCCESS(localState, {});
expect(localState.isLoading).toEqual(false);
});
it('sets hasError to false', () => {
mutations.RECEIVE_REPORT_SUCCESS(localState, {});
expect(localState.hasError).toEqual(false);
});
it('sets report to response report', () => {
const report = { data: 'testing' };
mutations.RECEIVE_REPORT_SUCCESS(localState, report);
expect(localState.report).toEqual(report);
});
});
describe('RECEIVE_REPORT_ERROR', () => {
it('sets isLoading to false', () => {
mutations.RECEIVE_REPORT_ERROR(localState);
expect(localState.isLoading).toEqual(false);
});
it('sets hasError to true', () => {
mutations.RECEIVE_REPORT_ERROR(localState);
expect(localState.hasError).toEqual(true);
});
});
});
|