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
|
import { getJSONFixture } from 'helpers/fixtures';
import * as types from '~/pipelines/stores/test_reports/mutation_types';
import mutations from '~/pipelines/stores/test_reports/mutations';
describe('Mutations TestReports Store', () => {
let mockState;
const testReports = getJSONFixture('pipelines/test_report.json');
const defaultState = {
endpoint: '',
testReports: {},
selectedSuite: null,
isLoading: false,
};
beforeEach(() => {
mockState = { ...defaultState };
});
describe('set suite', () => {
it('should set the suite at the given index', () => {
mockState.testReports = testReports;
const suite = { name: 'test_suite' };
const index = 0;
const expectedState = { ...mockState };
expectedState.testReports.test_suites[index] = { suite, hasFullSuite: true };
mutations[types.SET_SUITE](mockState, { suite, index });
expect(mockState.testReports.test_suites[index]).toEqual(
expectedState.testReports.test_suites[index],
);
});
});
describe('set selected suite index', () => {
it('should set selectedSuiteIndex', () => {
const selectedSuiteIndex = 0;
mutations[types.SET_SELECTED_SUITE_INDEX](mockState, selectedSuiteIndex);
expect(mockState.selectedSuiteIndex).toEqual(selectedSuiteIndex);
});
});
describe('set summary', () => {
it('should set summary', () => {
const summary = { total_count: 1 };
mutations[types.SET_SUMMARY](mockState, summary);
expect(mockState.testReports).toEqual(summary);
});
});
describe('toggle loading', () => {
it('should set to true', () => {
const expectedState = { ...mockState, isLoading: true };
mutations[types.TOGGLE_LOADING](mockState);
expect(mockState.isLoading).toEqual(expectedState.isLoading);
});
it('should toggle back to false', () => {
const expectedState = { ...mockState, isLoading: false };
mockState.isLoading = true;
mutations[types.TOGGLE_LOADING](mockState);
expect(mockState.isLoading).toEqual(expectedState.isLoading);
});
});
});
|